Algorithm 3LDP
| Input: Initialized shape assembly xp |
| Output: Resulting shape assembly xo and the associated oriented boundaries. |
| begin |
| 1. For each object Oi(1≤i≤m), do steps 2 to 4. |
| 2. Determine sets of points for Oi in I. |
| 3. Determine costs κ(u,v) via first level DP for all directed arcs in Fig. 1. |
| 4. For each point u in , determine the best directed path from u back to u via the second level DP, the corresponding shape xOi, and its total cost Ki(xOi). |
| 5. Compute arc costs in Fig. 2. Find the best path xo which has minimal total cost in the graph of Fig. 2 via third level DP. |
| 6. Output the optimum shape assembly xo and the corresponding oriented boundaries. |
| end |