1 Introduction

Insertability analysis, which is the problem of assessing whether a rigid body can be inserted into a tight-fitting cavity, is ubiquitous in a wide range of engineering applications. In automated tooling, for example, it is used to plan an interference-free path for inserting robotically guided parts into mating fixtures (Canny 1988; Oliver and Huang 1994). In molding, it is used to ensure that the part can be extracted from the core and cavity without excessive force (Carley 1993). And in engineering design, it is used to design tightly fitting parts and establish tolerances for assemblability (Shen et al. 2005). In particular, with respect to the design of orthopedic implants, where a tight fit with the host bone is usually required, insertability analysis plays a key role in avoiding obstructing geometry and stuck configurations.

With advances in medical imaging and computational analysis, virtual models of a patient’s specific anatomy can be synthesized and used to develop custom orthopedic implants, designed to best fit the patient’s unique anatomy. These implants may also be optimized for maximum long-term performance by simulating their effect on the host bony tissue. Nonetheless, the design of patient-specific implants is fraught with new technical challenges, not least of which is the requirement that the implant be insertable into the host bone tissue, without interference. The insertability requirement is particularly difficult to incorporate into a design optimization framework because of (1) the tight-fitting nature of the bone-implant system, and (2) the need for a differentiable insertability metric.

The problem of assessing the insertability of tight-fitting components has been extensively studied in the field of robotics, where it is known as the peg-in-hole problem (Sacks and Joskowicz 1995). It is typically treated as a special instance of the general path planning problem, wherein the goal is to determine how to insert a movable body (the peg) into a stationary cavity (the hole) without interference (Latombe 2012). What makes the peg-in-hole problem challenging is that the body and cavity share nearly complementary geometry in the inserted configuration, resulting in highly constrained movement. This feature significantly decreases the efficiency and efficacy of traditional path-planning strategies, especially when considering 3D motion and complex geometry. Traditionally, solving the peg-in-hole problem involves searching the space of all possible physical configurations (configuration space) for a continuous non-overlapping set of interference-free configurations leading from an initial uninserted configuration to a final inserted configuration (Joskowicz and Taylor 1996). The search for an insertion path involves two tasks: (1)  determining if a particular configuration is interference-free, and (2) planning a path between interference-free configurations. How and when these tasks are performed is determined by the particular path-planning strategy employed. These strategies can be categorized as either global or local, based on how they explore the configuration space.

Global path planning strategies first construct and partition the entire configuration space into cells, individually assessing each cell for interference. Path planning is performed only once the configuration space has been fully mapped out. These strategies are effective when the topography of the configuration space can be captured with a reasonably coarse sampling. However, for tight-fitting insertion problems, where the shapes are complex and the clearance is small, a prohibitively fine sampling may be required in the vicinity of the inserted configuration. This is exacerbated by the high computational cost of the methods used to assess interference, which typically involve dividing the geometry into fine polyhedra and repeatedly testing for overlap between the polyhedra of different bodies. Moreover, for tight-fitting bodies, where small incremental movements are required for insertion, simplification of the geometry or reduction of the configuration space is not possible. Therefore, techniques such as hierarchical decomposition (Faverjon 1984; Zhu and Latombe 1989), geometry simplification (Hwang et al. 2003), or selective exploration of configuration space (Kavraki and Latombe 1994; Karaman and Frazzoli 2011) are not applicable, meaning that complete mapping of the configuration space remains infeasible.

Local path planning strategies reduce the number of interference assessments by starting from an initial configuration and using local information to move toward the intended final configuration, mapping out the configuration space only as needed. Conventional local path-planning algorithms, such as artificial potential fields, Dijkstra, A*, D*, and rapidly exploring random trees (Siciliano et al. 2008), are often able to plan and adapt a path based on new environmental information but tend to be computationally expensive or become unstable in tight-fitting environments (Ayawli et al. 2018). Intelligent reactive approaches search the configuration space more efficiently by leveraging nature-inspired principles (Mac et al. 2016). Among these, genetic algorithms, artificial neural networks, and fuzzy logic have proven effective in navigating some specific types of environments (Siddique and Adeli 2015).

Despite these advances, few path-planning strategies are efficient in navigating tight-fitting environments with complex geometry. One exception is a method proposed by Joskowicz and Taylor (1996), which specifically targets the peg-in-hole problem by exploiting the tight fit and known insertion direction. It works by partitioning the cavity into neighborhoods. These neighborhoods, defined by convex polyhedra, are then used to generate a set of linear constraints that ensure non-interference, thereby eliminating the need for overlap tests. The algorithm seeks out a sequence of small movements by formulating, for each successive movement, a linear optimization problem in which a move-related task function is minimized while subject to a set of neighborhood constraints. This method significantly reduces the cost of each movement. Yet, like other path-planning approaches, it involves searching for a complete path, which may be made up of many individual configurations, each adding to the computational cost of the insertability assessment.

Related to insertability is the problem of ensuring accessibility for machining. Langelaar (2019) suggested a constraint developed for multi-axis machining. This method assesses whether a particular design can be machined from a block of material by effectively making sure that any material to be removed is accessible from one of several prescribed insertion directions. If a single insertion direction is considered, any cavity which can be created by the tool can be interpreted as a hole for which there exists a complementary peg. This method is highly efficient since the insertion path is known. Moreover, it provides gradient information that can be used in design optimization. Nonetheless, it is effective only when an exact rectilinear insertion direction is provided and rotation along the insertion path can be omitted.

In this paper, we present a novel approach that exploits the tight-fitting condition to assess insertability without computing the entire insertion path. We represent insertability as a continuously differentiable function that can be incorporated into gradient-based optimization to ensure that, to the extent that is possible, the optimized design satisfies the insertability requirement, together with the other design specifications. The insertability analysis can, then, be performed throughout the design process, rather than as a validation tool.

We formulate the insertability problem as a path-planning problem in which the object is initially fully inserted. The objective is to determine if there exists a path from this inserted configuration to some uninserted configuration. We eliminate the need to construct the full path by exploiting the fact that the body and cavity shapes are nearly complementary, which is typically the case in the design and optimization of implants. We prove that if there exists any infinitesimal interference-free movement which moves the body slightly out of the cavity, then the object can be fully extracted, without interference. We demonstrate how our formulation can be employed as a design tool for both generic shape optimization and for advanced structural optimization.

The remainder of this paper is organized as follows. Section 2 describes the novel insertability metric and the related interference-free criterion. Section 3 presents a shape optimization strategy that incorporates the insertability metric as a design constraint. Section 4 explores an application of the insertability constraint to the optimization of a patient-specific acetabular cup for use in hip replacement surgery. Finally, Sects. 5 and 6 conclude with a discussion and summary of the numerical results.

2 Insertability

Consider the perfectly complementary body-cavity system shown in Fig. 1. If the body is slightly rotated, as shown, clearance will be created in some areas (green) and interference will be introduced in others (red). In areas with clearance, points along the body surface are displaced in the direction of the local cavity surface normal, while in areas with interference, they are displaced in the negative normal direction. If all points along the body surface move in the direction of the local cavity wall normal, the configuration is interference-free. The question thus becomes whether there exists such a rigid body motion. This observation eliminates the need for the computationally expensive geometry subdivision and overlap testing commonly used to assess interference. The following describes how interference is assessed mathematically.

Fig. 1
figure 1

A body-cavity system shown before and after a small body movement. Clearance and interference are shown in green and red, respectively. Local cavity surface normals are shown in yellow. Sample body surface vertices in areas with interference are displaced in the negative normal direction, while body surface vertices in areas with clearance are displaced in the positive normal direction. (Color figure online)

We define the movable object B as a rigid 3D body with 6 degrees of freedom (DOF), and the open cavity C as a fixed rigid 3D obstacle, as illustrated in Fig. 2. We further define the cavity interior I as the empty space within C, and the cavity exterior E as \({\mathbb {R}}\backslash I\). Finally, the body-cavity interface \(\Gamma\) includes the complementary surfaces of B and C, which are assumed perfectly coincident. We define a fixed global coordinate system and a movable frame associated with B.

Fig. 2
figure 2

Illustration of an original (left) and partitioned (right) body-cavity system

We describe a configuration as the set \(({\textbf{p}},\varvec{\theta })\), made up of three displacements, \({\textbf{p}}\), and three rotations, \(\varvec{\theta }\), with respect to the fixed coordinate frame.

In a configuration \(({\textbf{p}},\varvec{\theta })\), the position, \({\textbf{v}}\), of a body point, \({\textbf{b}}\) is expressed as

$$\begin{aligned} {\textbf{v}} = \textrm{F}({\textbf{p}},\varvec{\theta }) \cdot {\textbf{b}} = \textrm{Rot}(\varvec{\theta }) \cdot {\textbf{b}} + {\textbf{p}} \end{aligned}$$
(1)

where \(\textrm{Rot}(\varvec{\theta })\) is the rotation matrix specifying the orientation of the body.

Consider now the rigid body motion \({\textrm{T}:({\textbf{p}}^0,\varvec{\theta }^0) \rightarrow ({\textbf{p}}^*,\varvec{\theta }^*)}\), which maps from an initial configuration \(({\textbf{p}}^0,\varvec{\theta }^0)\) to a new configuration \(({\textbf{p}}^*,\varvec{\theta }^*)\). The resulting displacement for a point \({\textbf{b}}\) is:

$$\begin{aligned} {\textbf{r}}_b = \textrm{F}({\textbf{p}}^*,\varvec{\theta }^*) \cdot {\textbf{b}} - \textrm{F}({\textbf{p}}^0,\varvec{\theta }^0) \cdot {\textbf{b}} \end{aligned}$$
(2)

If point \({\textbf{b}}\) is on the body-cavity interface, \(\Gamma\), in \(({\textbf{p}}^0,\varvec{\theta }^0)\), \({\textbf{r}}_b\) may be expressed in terms of local interface normal and interface tangent components, \(\hat{\mathbf {{n}}}_b\) and \(\hat{\mathbf {{t}}}_b\), as illustrated in Fig. 3:

$$\begin{aligned} {\textbf{r}}_b = r_b^n \hat{\mathbf {{n}}}_b + r_b^t \hat{\mathbf {{t}}}_b \end{aligned}$$
(3)

where \({\hat{\textbf{n}}}_b\) is defined as pointing toward the cavity interior.

Fig. 3
figure 3

A body-cavity system in its inserted configuration, \(C^0\), (left) and a perturbed configuration, \(C^*\) (center). The net displacement of a point \({\textbf{b}}\) from \(v_0\) to \(v_*\) of an arbitrary interface point (red) is decomposed into interface normal and tangent components, with respect to the interface in configuration \(C^0\). The minimum normal displacement, as defined in Eq. 5, is shown for a case in which \(r^n = r_\text{min}^n\). (Color figure online)

2.1 Interference-free criterion

Interference is defined as the condition in which two bodies overlap at some point in space. For a continuous motion, starting from a tight-fitting configuration, interference can only initiate where both bodies were previously coincident. Therefore, analysis of the instantaneous velocities of the bodies along their interface can predict subsequent interference.

Let us now consider a motion \(\textrm{T}:({\textbf{p}}^0,\varvec{\theta }^0) \rightarrow ({\textbf{p}}^*,\varvec{\theta }^*)\) which results in an infinitesimally small movement of the body. If the resulting displacement \({\textbf{r}}_b\) of a point \({\textbf{b}}\) on the interface \(\Gamma\) is positive with respect to the local normal, i.e.,

$$\begin{aligned} {\textbf{r}}_b = r_b^n \hat{\mathbf {{n}}}_b, \ r_b^n \ge 0 \end{aligned}$$
(4)

then it can be said that \(\textrm{T}\) is collision-free with respect to \({\textbf{b}}\).

For the general case in which the tangential displacement is non-zero, the displacements should be limited based on the shared local interface curvature, \(\kappa _b\). If the local curvature is less than or equal to 0, the minimum normal displacement is unrelated to the tangential displacement. However, when the local curvature is positive, a purely tangential displacement causes interference. In this case, a minimum normal displacement \(r_\text{min}^n\) is defined based on the local interface curvature, \(\kappa\), and the tangential displacement \(r_b^t\), as shown on the bottom right of Fig. 3. Graphically, \(r_\text{min}^n\) is the distance in the normal direction \({\hat{n}}_b\) from \(v_b^0\) to the intersection of the local curvature circle and a line parallel to \(r_b^n\) through the point \(v_b^0 + r_b^t {\hat{t}}_b\). Mathematically, \(r_\text{min}^n\) is given by:

$$\begin{aligned} r_\text{min}^n = {\left\{ \begin{array}{ll} \kappa ^{-1} - \sqrt{\frac{\kappa ^{-2} (r_b^t)^2}{\kappa ^{-2} - (r_b^t)^2}} \quad &{}\text {if} \, \kappa _b > 0 \\ 0 \quad &{}\text {otherwise} \\ \end{array}\right. } \end{aligned}$$
(5)

and Eq. 4 is replaced by the general local Interference-free criterion

$$\begin{aligned} r_b^n \ge r_\text{min}^n \end{aligned}$$
(6)

Since we are concerned with infinitesimal displacements, the local curvature is not expected to change significantly from \(v^0\) to \(v^*\). The constraint is, therefore, sufficient to prevent interference.

If Eq. 6 is respected for all points along \(\Gamma\), then \(\textrm{T}\) is interference-free. This can be expressed as:

$$\begin{aligned} {\mathcal {I}} = \underset{b\in \Gamma }{max}\ \left( r_\text{min}^n - r_b^n \right) \le 0 \end{aligned}$$
(7)

To facilitate differentiability, the Kreisselmeier-Steinhauser (KS) function commonly employed in numerical optimization (Kreisselmeier and Steinhauser 1980; Akgun et al. 1999; Poon and Martins 2007) is used to approximate the maximum function. The final Interference-free criterion is then expressed as:

$$\begin{aligned} {\mathcal {I}} \approx \underset{b\in \Gamma }{\textrm{KS}} \left( r_\text{min}^n - r_b^n \right) = \frac{1}{\rho } \text {ln}\sum _{b\in \Gamma }e^{\rho \left(r_\text{min}^n - r_b^n \right)} \le 0 \end{aligned}$$
(8)

where \(\rho\) is a tuning parameter, typically in the range 100–1000.

2.2 Path planning

Traditionally, insertability analysis requires the iterative computation of a complete path between the inserted and extracted configurations. The high computational cost associated with this process is exacerbated when full 6 DOF motion and complex geometry are considered. Here, we exploit the tight-fitting condition to circumvent the process entirely.

Consider the perfectly complementary body-cavity system shown in Fig. 4 and an interference-free transformation \(\textrm{T}:({\textbf{p}}^0,\varvec{\theta }^0) \rightarrow ({\textbf{p}}^*,\varvec{\theta }^*)\). \(\textrm{T}\) is defined as non-reentrant if it results in an exclusively outward movement of the body with respect to the cavity. In other words, any point b on the cavity opening O in the initial configuration must either remain on O or move to the cavity exterior E, as a result of the movement \(\textrm{T}\), i.e.,

$$\begin{aligned} {\textbf{v}}_b^* \in (O \cup E), \ \forall \ {\textbf{v}}_b^0 \in O \end{aligned}$$
(9)

If there exists a non-zero \(\textrm{T}\) which simultaneously satisfies the non-reentrance and the interference-free criteria, it can be proven that successive application of the same transformation \(\textrm{T}\) on B will always be interference-free and will eventually lead to full extraction from the cavity. In other words, \(\textrm{T}\) describes a full interference-free extraction/insertion path.

Property 1

Successive application of \(\textrm{T}\) on B is always interference-free

Proof

Consider a body point \({\textbf{b}}_j\) which initially lies inside the cavity interior I. The transformation \(\textrm{T}\left(({\textbf{p}}^0,\varvec{\theta }^0) \rightarrow ({\textbf{p}}^*,\varvec{\theta }^*),{\textbf{b}}_j \right)\) moves \({\textbf{b}}_j\) from \({\textbf{v}}_j^0 \in I\) to \({\textbf{v}}_j^* \in (I \cup E)\). If \({\textbf{v}}_j^* \in E\), then \(\textrm{T}\left(({\textbf{p}}^*,\varvec{\theta }^*) \rightarrow ({\textbf{p}}^{**},\varvec{\theta }^{**}),{\textbf{b}}_j \right)\) moves \({\textbf{b}}_j\) from \({\textbf{v}}_j^*\) to \({\textbf{v}}_j^{**} \notin I\) (case 1), since \(\textrm{T}\) satisfies the non-reentrance criterion. Otherwise, if \({\textbf{v}}_j^* \in I\) (case 2), then \({\textbf{v}}_j^*\) is coincident with some position \({\textbf{v}}_k\) corresponding to a body point \({\textbf{b}}_k\) in the initial configuration \(({\textbf{p}}^0,\varvec{\theta }^0)\). Since \(\textrm{T}\left(({\textbf{p}}^0,\varvec{\theta }^0) \rightarrow ({\textbf{p}}^*,\varvec{\theta }^*),{\textbf{b}}_k \right)\) was interference-free, \(\textrm{T}\left(({\textbf{p}}^*,\varvec{\theta }^*) \rightarrow ({\textbf{p}}^{**},\varvec{\theta }^{**}),{\textbf{b}}_j \right)\) is guaranteed to be interference-free. Thus, repeated application of \(\textrm{T}\) on B will always be interference-free.

Property 2

Successive application of \(\textrm{T}\) on B eventually leads to complete extraction

Proof

Excluding the trivial zero-displacement solution, any transformation \(\textrm{T}\) which satisfies the non-reentrance constraint results in a portion of the body exiting the cavity. Suppose \(\textrm{T}\) moves \({\textbf{b}}_j\) from \({\textbf{v}}_j^0 \in O\) to \({\textbf{v}}_j^* \in E\). Given that B is a single continuous entity, \(\textrm{T}\) moves some \({\textbf{b}}_k\) from \({\textbf{v}}_k^0 \in I\) to \({\textbf{v}}_j^0 \in O\). This means that each application of \(\textrm{T}\) on B causes some portion of B to exit the cavity. Since B is always purely exiting, repeated application of \(\textrm{T}\) will eventually lead to the full extraction of B.

Fig. 4
figure 4

An illustration of both possible scenarios resulting from the application of transformation \(\textrm{T}\) to a body point \(b_j\). In case 1, \(b_j\) moves from \(v_j^0\) to \(v_j^*\), which lies outside of the cavity interior. In case 2, \(b_j\) moves from \(v_j^0\) to \(v_j^*\), which overlaps with the position \(v_k^0\) of some point \(b_k\) in the initial configuration \(C_0\)

The process of assessing whether a body-cavity system is insertable along a path described by the movement T is described in Algorithm 1. The algorithm reports the degree of insertability, measured by the amount of interference (Eq. 8. This scalar-valued metric allows an optimization routine to find the motion which minimizes interference.

figure a

3 Design optimization

The proposed insertability metric, defined as the scalar output of Eq. 8, can be used as an efficient design validation tool. However, it is most effectively used as a constraint in structural optimization. To demonstrate this, we formulate a shape/topology optimization problem, following a common level set approach (Andreasen et al. 2020). This formulation is ideally suited to the interference constraint since it provides a crisp interface and allows for an efficient representation of arbitrarily complex topology (Van Dijk et al. 2013).

The following sections describe the level set method and provide detail on how the insertability constraint is implemented.

3.1 Design parametrization

The continuous body-cavity system is represented as a discrete nodal level set field on a regular grid, as shown in Fig. 5. The surface geometry is defined as the zero contour of the level set \(\varvec{\Gamma }\), with \(\phi _i > 0\) designating the interior of the body, and \(\phi _i < 0\) designating the exterior. The positions of the zero contour vertices \(\varvec{\Gamma }_{{\textbf{x}}}\) are linearly interpolated from the nodal level set values according to:

$$\begin{aligned} \varvec{\Gamma }_{{\textbf{x}}_i} = \frac{|\phi _i^{p1}| {\textbf{x}}_i^{p2} +|\phi _i^{p2}| {\textbf{x}}_i^{p1} }{|\phi _i^{p1}| + |\phi _i^{p2}| } \end{aligned}$$
(10)

where \({\textbf{x}}_i^{p1}\) and \({\textbf{x}}_i^{p2}\) represents the field values of the parent nodes, associated with \(\phi _i^{p1}\) and \(\phi _i^{p2}\), respectively.

Fig. 5
figure 5

An illustration of a continuous body-cavity system (left), approximated as a discrete level set \(\varvec{\phi }\) (right). The level set zero contour \(\varvec{\Gamma }\) is partitioned into interface vertices (red) and external vertices (black). By convention, \(\varvec{\phi } > 0\) on the interior and \(\varvec{\phi } < 0\) on the exterior. (Color figure online)

This representation provides a crisp interface and automatically generates a set of sample interface points for assessing insertability, along with their respective surface normals and curvature.

3.1.1 Interface properties

The zero contour \(\varvec{\Gamma }\) provides a polygonal representation of the smooth geometry. In spite of this, the local normal and curvature information at the vertices can be readily obtained from the gradient of the level set field:

$$\begin{aligned} \nabla \phi _{l,m,n}&= \left[ \frac{\partial \phi _{l,m,n}}{\partial x}, \frac{\partial \phi _{l,m,n}}{\partial y}, \frac{\partial \phi _{l,m,n}}{\partial z} \right]^T \end{aligned}$$
(11)
$$\begin{aligned} \frac{\partial \phi _{l,m,n}}{\partial x}&= \frac{\phi _{l+1,m,n} - \phi _{l-1,m,n}}{2 \Delta x} \end{aligned}$$
(12)

where \(\phi _{l-1,m,n}\) and \(\phi _{l+1,m,n}\) are the neighboring level set values in the x-direction. The other terms are calculated accordingly for each physical dimension.

The nodal unit normal vectors are obtained by normalizing the local gradient, i.e.,

$$\begin{aligned} \hat{{\textbf{n}}} = \frac{\nabla \phi }{||\nabla \phi ||} \end{aligned}$$
(13)

and the curvature is obtained as the divergence of the normalized gradient field:

$$\begin{aligned} \kappa = \nabla \cdot \frac{\nabla \phi }{||\nabla \phi ||} \end{aligned}$$
(14)

The zero contour unit normals \(\varvec{\Gamma }_{\hat{{\textbf{n}}}}\) and curvature \(\varvec{\Gamma }_{\kappa }\) are interpolated from \(\hat{{\textbf{n}}}\) and \(\kappa\) via Eq. 10.

3.1.2 Partitioning

Finally, the body level set zero contour vertices are partitioned into a set of body-cavity interface vertices and a set of external vertices. This is achieved by converting the immersed region (cavity body and interior) into a level set \(\varvec{\psi }({\textbf{x}})\), and interpolating its value at each body contour vertex. Positive values correspond to interface vertices and negative values correspond to external vertices.

The discrete field of design variables is not used directly as a level set. Instead, we follow the filter-projection-scaling method presented in (Andreasen et al. 2020) to ensure stability and mesh independency. The three stages are described briefly here, for completeness.

3.1.3 Filtering

Firstly, the raw field of design variables, \({\textbf{s}}\), is filtered to \(\tilde{{\textbf{s}}}\). The standard Helmholtz filter, introduced by Lazarov and Sigmund (2011), produces a smoothed field \(\tilde{{\textbf{s}}}\) as the solution of the equation

$$\begin{aligned} -r^2 \nabla ^2 \tilde{{\textbf{s}}} + \tilde{{\textbf{s}}} = {\textbf{s}} \end{aligned}$$
(15)

with homogeneous Neumann boundary condition \(\frac{\partial {\tilde{s}}}{\partial {\textbf{n}}} = 0\) imposed on the boundary of the design domain. The radius parameter r defines the smoothing strength.

3.1.4 Projection

The projection stage applies the smoothed Heaviside function frequently used in robust topology optimization (Wang et al. 2011), to sharpen the filtered design. This stage helps stabilize the optimization procedure and can be used to generate additional eroded and dilated variants, in the case of robust optimization.

$$\begin{aligned} \hat{{\textbf{s}}} = \frac{\text {tan}h(\beta \eta ) + \text {tan}h(\beta (\tilde{{\textbf{s}}}-\eta ))}{\text {tan}h(\beta \eta ) + \text {tan}h(\beta (1-\eta ))} \end{aligned}$$
(16)

where \(\eta\) is a threshold parameter, and \(\beta\) controls the steepness of the projection. Throughout this work, \(\eta = 0.5\) and \(\beta = 12\).

3.1.5 Scaling

The final scaling step ensures that \(\phi \in [\phi _\text{min};\phi _\text{max}]\), through linear rescaling, i.e.,

$$\begin{aligned} \varvec{\phi } = \phi _\text{min} + (\phi _\text{max}-\phi _\text{min}) \hat{{\textbf{s}}} \end{aligned}$$
(17)

The interval is chosen as \(\varvec{\phi } \in [-h/2; h/2]\), where h is the side length of a grid element, following Sharma and Maute (2018) and Andreasen et al. (2020).

3.2 Shape modification for insertability

As a first example, we consider a number of 2D and 3D body-cavity systems and use the proposed insertability metric to assess whether they are insertable and, if not, determine how they can be modified to ensure insertability. To that end, we formulate an optimization problem wherein the objective is to minimize a cost function, defined as total shape change (Eq. 18, and the insertability requirement (Eq. 8) is included as a constraint. This formulation ensures that the design will be rendered insertable while changing the shape as little as possible. The optimization routine then aims to simultaneously find the optimal shape, together with the optimal insertion motion, as defined by \({\textbf{s}}\) and \(\textrm{T}\).

The shape match function is defined as:

$$\begin{aligned} F_S = \frac{1}{n} \sum _{i=1}^n | \textrm{d}({\textbf{b}}_i, S_0) | \end{aligned}$$
(18)

where \(\textrm{d}({\textbf{b}}_i, S_0)\) is the closest distance from a point \({b}_i\) on the evolving body surface to a point cloud describing the original geometry \(S_0\), which can be interpolated from a pre-computed signed distance field. The resulting constrained optimization problem is solved by mathematical programming using the method of moving asymptotes (MMA)  (Svanberg 1987). The procedure for optimizing a design for insertability is shown in Algorithm 2. It is also necessary to exclude the trivial solution with transformation \(\textrm{T}\) resulting in a trivial zero displacement, as it does not guarantee insertability. This is achieved by imposing a constraint on the minimum net displacement of the body subject to \(\textrm{T}\).

figure b
Fig. 6
figure 6

Various 2D body-cavity systems modified for insertability using Eq. 18 as the design objective. The original designs (top row) fail to meet the local interference-free criterion at the highlighted points (red). The modified designs (bottom row) are presented along with the local shape change from the original design, shown as magenta vectors. The crosshatching designates the cavity wall. All designs use  \(2\times 10^{4}\) node level set meshes with a filter radius of \(r = 6\). (Color figure online)

Four uninsertable designs are shown in the top row of Fig. 6. The corresponding optimized designs are shown in the bottom row. In each case, the extraction direction is shown by an arrow, and the areas which locally violate the insertability constraint are highlighted in red. Once the iterative optimization procedure has converged, the shape has been modified to eliminate all local interference. Magenta lines highlight the local shape change from the original design.

In the first case, the initial design is axisymmetric and the interference is localized around the undercuts, as shown. The modified design eliminates the undercuts to produce a straight shaft. In the second case, double-curvature is present, resulting in three regions with local interference. The algorithm simultaneously eliminates the double-curvature and modifies the extraction direction to eliminate the interference. The third case is similar to the first and is included to show that the algorithm can handle complex topology such as internal cavities. In this instance, a flooding algorithm (Heckbert 1990) is used to distinguish the internal and external contours. Finally, case four highlights the algorithm’s ability to handle large rotations. In this instance, the contour is modified to smooth out the protrusion, while largely maintaining its curvature.

3.2.1 Space-filling

Another noteworthy feature of these results is that the algorithm tends to move interface inwards in some areas and outwards in others. In cases where both the body and cavity can be modified, this is adequate. However, in many cases, the cavity geometry is prescribed, and the objective may be to design a body that maximally fills the cavity. In this case, the space-filling version of the shape match function may be used:

$$\begin{aligned} F_{S^*} = \frac{1}{n} \sum _{i=1}^n {\left\{ \begin{array}{ll} \alpha |\textrm{d}({\textbf{b}}_i, S)| \quad &{}\text {if} \, \textrm{d}({\textbf{b}}_i, S) < 0 \\ \beta |\textrm{d}({\textbf{b}}_i, S)| \quad &{}\text {if} \, \textrm{d}({\textbf{b}}_i, S) \ge 0 \\ \end{array}\right. } \end{aligned}$$
(19)

where \(\alpha\) and \(\beta\) are tuning parameters, with \(\alpha>>\beta\). This ensures that outwards changes are more expensive than inward changes. The same original designs presented in Fig. 6 are modified using the shape-filling objective. Results are shown in the top row of Fig. 7. In each case, the cavity is unchanged and the design is reduced in order to comply with the insertability constraint.

3.2.2 Space-making

We also consider a scenario in which only the cavity can be modified, or in which the body must at least occupy the same space as the original. The direction-distinguishing version of the shape-matching function Eq.  19 can be used with \(\alpha<<\beta\). Results obtained using this space-making version are presented in the bottom row of Fig. 7. Here, the results refer to the scenario where both body and cavity can be modified. In the case where only the cavity can be modified, the modified interface would be as shown, but the body would remain unchanged.

Fig. 7
figure 7

Results obtained by applying the space-filling (top row) and space-making (bottom row) objectives to the original designs from Fig. 6

3.2.3 3D design

The same method is equally applicable to the modification of 3D designs. Various 3D original and modified designs are presented in Fig. 8. In 3D, more complex movements are possible. For example, the third example involves a corkscrew motion about the vertical axis. The algorithm successfully identifies the appropriate transformation vector automatically. As for the 2D case, the space-filling and space-making versions may be used instead of the original shape-matching function. Space-making and space-filling results are presented in the lower half of Fig. 8. Numerical results for all studies are included in Table 1.

Fig. 8
figure 8

Various 3D body-cavity systems modified for insertability using Eq. 18 as design objective. The original designs (top row) fail to meet the local interference-free criterion at the highlighted areas (left). The modified designs (bottom rows) are presented along with the local shape change from the original design (right). Red and green refer to added and removed material, respectively. The third and fourth rows use the space-filling and space-making variations of the shape-match functions. All designs were generated on  500,000 node level set meshes with a filter radius of \(r = 4\). (Color figure online)

3.3 Discussion on parameters

3.3.1 Ease of insertion

The insertability constraint is defined as an inequality with the right side set to zero. This, in effect, allows for pure sliding motion along the body-cavity interface. In certain applications, such as in automated assembly, this can result in designs that are difficult to insert. If, for example, the body and cavity have rough surfaces, the resulting friction may require high forces or prevent insertion entirely. This can be addressed by setting the right side of the inequality constraint to \(\varepsilon \le 0\). Figure 9 shows how the design of a straight bar is affected for various values of \(\varepsilon\).

Fig. 9
figure 9

ac Three versions of a straight rod, each modified for insertability with different \(\varepsilon\) values. From left to right, \(\varepsilon = {0}\), \(\varepsilon = -1 \times 10^{-2}\), \(\varepsilon = -1 \times 10^{-1}\). d Shows how the exterior portion of the design in c can be overwritten with the original geometry from a

3.3.2 Filter radius

A minor issue highlighted by these results is the unnecessary dilation near the cavity opening. This results from the filtering stage described above. While it may be possible to eliminate this issue by increasing the tuning parameters in the projection stage, it is generally sufficient to replace the exterior portion of the modified design with that of the original, as shown in Fig. 9d.

We note that in some cases, the modified design does not maximally fill the cavity. In cases 2 and 3, for example, the implant should touch the bottom of the cavity, but does not. This is likely related to the filtering and may be addressed by either adjusting the tuning parameters or refining the level-set grid.

3.4 Convergence

The convergence history for a selection of the case studies, chosen at random, is shown in Fig. 10. In all cases, the interference constraint is initially normalized. The optimization history reveals a generally smooth evolution in which the design is first changed significantly at the expense of the objective function, in order to bring the interference constraint below zero. Subsequent iterations minimize the shape match objective. The optimization tends to converge within less than 100 iterations. Note that in the 2D case (Fig. 7a), the observed instability between iterations 75 and 110 results from a coarse mesh discretization and a large step size.

Fig. 10
figure 10

Optimization history for three case studies, one for each of the 2D, 3D and 3D acetabular cup sets

4 Application to the design of acetabular cups

Orthopedic implants are medical devices used to replace damaged or missing bone tissue in an effort to improve the patient’s mobility, reduce pain, and generally improve quality of life. Traditional implant systems include a set of generic implant shapes and sizes to help find the best fit. However, patient-specific implants (PSI), designed according to a patient’s unique anatomy, may offer better outcomes than their traditional counterparts. Some of the expected benefits of patient-specific implants include: better positional accuracy of the joint, reduced risk of complications, and reduced recovery times (Small et al. 2014; Spencer-Gardner et al. 2016; Maniar and Singhi 2014).

A particularly challenging aspect in the design of patient-specific implants is the need to optimize functional compatibility between the implant and the surrounding bone tissue, while also ensuring that the implant can be inserted without causing damage to itself or to the peri-prosthetic tissue. The method presented in this work is ideally suited to address these potentially conflicting design objectives. In this section, we demonstrate how our insertability constraint can be applied to the design of an acetabular cup, considering both geometric and structural objectives, via finite element analysis (FEM).

The acetabular cup is the female component of a hip replacement implant (Fig. 11). It is a typically hemispherical component that is placed in the acetabulum, which is the socket of the pelvis that forms the hip joint. Traditionally, orthopedic surgeons determine the ideal diameter of the cup from a range of options, based on patient-specific measurements. However, since the surface of the acetabulum is not perfectly hemispherical, there is always some morphological mismatch between the cup and the acetabulum. This mismatch may reduce the implant’s stability and cause damage to the surrounding cortical bone.

Fig. 11
figure 11

An illustration of the total hip replacement (THR) procedure with a generic hemispherical acetabular cup. Reaming ensures proper contact between the bone and cup along the exterior, but pockets are present on the interior. Screws (not shown) may be included to help stabilize the cup

As a first approach, we can apply the shape-matching formulation subject to our insertability constraint, as described above. However, we must first generate a morphologically matched implant design to use as a starting point. This can be achieved by performing a CT scan of both hips and extracting the difference between the healthy and defective anatomy. If both hips are anatomically defective, we may use a computational model to obtain an approximate reconstruction of the original healthy bone. In this work, we use a pre-processed set of defective and reconstructed pelvis geometry obtained from Meynen et al. (2020). The defective pelvis, which is classified as type IIA according to the Paprosky classification system, is reconstructed using a statistical shape model based on data from 90 patients. By comparing the defective geometry, shown in Fig. 12a with the reconstructed healthy geometry, shown in Fig. 12b, we can identify the missing acetabular tissue and the ideal bone-implant contact surface. The missing tissue geometry is then used to create an implant with a perfectly matching bone contact surface, as well as the required hemispherical bearing surface for the synthetic joint, as shown in Fig. 13.

Fig. 12
figure 12

a A Paprosky classification type IIA defective pelvic bone extracted from CT data, b the reconstructed healthy bone obtained using the statistical shape modeling by Meynen et al. (2020, c the defective pelvic bone with the recovered acetabular tissue highlighted

Fig. 13
figure 13

The initial implant level set based on the geometry of the missing acetabular tissue. The bone-implant interface is highlighted in blue while the modified spherical bearing surface, required for finite element analysis, is highlighted in red. (Color figure online)

Results of the design process are presented in Fig. 14. Each column shows a different view of the implant-bone contact surface. The top row shows the values of the local insertability metric. The areas which prevent insertability are highlighted with circles. The bottom row shows the optimized implant with the local shape change shown in red and green. In this case, since cortical bone tissue can be resected but not added, green areas represent gaps between the implant and the bone. We can observe that the shape changes are concentrated on either side of the implant and that, for each, inwards and outwards changes are paired. This coupling makes the local surface parallel to the insertion direction, as would be expected for the nearly linear insertion path shown.

Fig. 14
figure 14

Row 1: Original implant design with local interference shown. Row 2: Implant modified using the standard shape-matching objective. Row 3: Implant modified using the space-filling objective. Row 4: Implant modified using the space-making objective. The added material (red) corresponds to local bone tissue resection, and the removed material (green) corresponds to gaps with the surrounding bone tissue. \(V_\text{in}\) and \(V_\text{out}\) represent the total inward and outward volumetric change, normalized to the initial design volume. (Color figure online)

If indicated, space-filling and space-making may be used instead. The space-filling design will preserve as much of the cortical bone tissue as possible but will result in some morphological mismatch. On the other hand, the space-making design will ensure a perfect contact surface but requires some bone resection.

Beyond the purely geometric shape-matching functions, more sophisticated objectives based on structural analysis of the bone-implant system may be considered. For example, we may aim to minimize the risk of implant slipping and loosening by assessing the global Hoffman failure criterion Hoffman (1967). This function assesses the local risk of interface fracture based on the cortical bone properties and the local stress conditions throughout the interface. With the Hoffman index set as the optimization objective and the insertability criterion set as the only constraint, and reduction in the Hoffman index of 94% is achieved (Fig. 15). The Hoffman criterion and the associated finite element methods are presented in Garner et al. (2022). Details regarding loads and boundary conditions are included in “Appendix A”.

Fig. 15
figure 15

The original (top row) and modified (middle row) implant designs colored according to the local risk of interface fracture from Garner et al. (2022). In the bottom row, the local shape change is shown in terms of added (red) and removed (green) material.\(V_\text{in}\) and \(V_\text{out}\) represent the total inward and outward volumetric change, normalized to the initial design volume. (Color figure online)

Table 1 Problem parameters and performance values for each numerical experiment

5 Discussion

The preceding examples demonstrate that the proposed insertability constraint can effectively and efficiently restrict the design of complex 2D and 3D structures subject to various geometry and structural requirements.

The method is implemented in MATLAB R2023a. All 2D and 3D results presented were computed on a laptop computer with M1 Max processor and 64 GB LPDDR5 RAM. The 2D shape optimization was performed with approximately 20,000 design variables and required 30–50 iterations, each performed in approximately 0.6 s. The 3D results were performed with approximately 500,000 variables and required 40–100 iterations, at 8–10 s per iteration. Compared with our MATLAB implementation of the method presented by Joskowicz and Taylor (1996), the 2D insertability assessment was performed approximately 70\(\times\) faster, primarily due to the computation of a complete insertion path.

The level set-based optimization framework proved highly effective as a host for the insertability constraint. Performance improved monotonically throughout the optimization procedure and converged in less than 100 iterations for all the experiments. The algorithm proved capable of handling complex topology and cases with large rotations in both 2D and 3D. No parameter tuning was required between numerical studies.

5.1 Limitations

The main limitation of the insertability metric is that it reduces the cavity to an interface curve (2D) or surface (3D), thereby ignoring possible interference between the fixed cavity body and the external/extracted portion of the moving body. For this reason, under certain circumstances, the insertability criterion may potentially produce false positive results. Handling of this special case may require additional constraints and is left as a challenge for future research.

5.2 Notes on implementation

For problems in which significant rotation is required for insertion/extraction, it is critical to choose an appropriate reference frame origin. Otherwise, the sensitivities of the constraint with respect to the rotations in \(\varvec{\theta }\) may become very large. This is generally avoided by setting the origin to the centroid of the initial design.

The insertability constraint tends to be sensitive to the filter radius. In particular, significant instability has been observed for \(r<4\). While a relatively large filter radius does tend to reduce the design complexity for a given grid size, sharper projection and finer grid resolution help mitigate this issue.

In a real-world application, designs should take into account manufacturing-related uncertainties. Methods such as the one presented by da Silva et al. (2019) help account for local defects on internal stresses. In the case of the proposed insertability constraint, small surface imperfections may impede insertion. We demonstrated how this can potentially be mitigated by tailoring the ease of insertion parameter \(\varepsilon\). However, a perfect fit in the inserted configuration remains tied to the accuracy of the manufactured components. For this reason, manufacturing uncertainty should be incorporated into the optimization framework, alongside the insertability constraint.

6 Conclusion

We have demonstrated that the proposed insertability metric is able to efficiently assess the insertability of complex body-cavity systems, taking into account full 6 DOF motion. Beyond its use as a validation tool, the insertability metric can be applied as a constraint in the design and optimization of functional components where geometric or structural objectives are considered. The level set-based formulation allows for straightforward integration with many topology optimization approaches. Future work will focus on applying the insertability constraint to multi-scale optimization in which both the overall shape and the internal microarchitecture of the architected material are optimized simultaneously.