approximate topological matching of quadrilateral meshes · 2013-06-20 · a maximum approximate...

23
Approximate Topological Matching of Quadrilateral Meshes David Eppstein * University of California, Irvine Michael T. Goodrich University of California, Irvine Ethan Kim McGill University Rasmus Tamstorf § Walt Disney Animation Studios ABSTRACT We study approximate topological matching of quadrilateral meshes, that is, the problem of finding as large a set as possible of matching portions of two quadrilateral meshes. This study is motivated by applications in graphics that involve shape modeling whose results need to be merged in order to produce a final unified representation of an object. We show that the problem of producing a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an exact solution ex- tremely unlikely, we show that the natural greedy algorithm de- rived from polynomial-time graph isomorphism can produce poor results, even when it is possible to find matches with only a few non-matching quads. Nevertheless, we provide a “lazy-greedy” al- gorithm that is guaranteed to find good matches when mis-matching portions of mesh are localized. Finally, we provide empirical evi- dence that this approach produces good matches between similar quad meshes. Index Terms: F.2.2 [Analysis of Algorithms and Problem Com- plexity]: Nonnumerical Algorithms and Problems—Geometrical problems and computations; I.3.5 [Computer Graphics]: Computa- tional Geometry and Object Modeling—Boundary representations 1 I NTRODUCTION Quadrilateral meshes represent polyhedral surfaces in such a way that each face is a quadrilateral, which is quite useful in computer graphics applications. The usefulness of these meshes comes in part from the fact that rectangular texture images are easily mapped without clipping into quadrilaterals (which we sometimes refer to as “quads”). Thus, quad meshes are desirable for surface modeling. Quad meshes are also useful in finite element analysis, where one desires adaptive refinement into regions of interest, since quadrilat- erals are easily partitioned into finer quadrilateral grids. Indeed, several mesh generation algorithms, such as that of Schonfeld and Weinerfelt (31) and others (1; 26; 34), begin with a coarse quadri- lateral mesh and then refine each quad of interest into a regular grid of sub-quads. In order to best utilize the time of people working with a given quad mesh, it is common for a single mesh to be used in a num- ber of different processing paths in parallel. For example, a single mesh might be processed simultaneously for texture mapping, fea- ture mapping, finite-element analysis for physical simulation pur- poses, and morphing for object animation. Unfortunately, the soft- ware systems that perform the multiple simultaneous tasks on a given mesh M often use different internal representations of M, which in turn result in different representations of M in the output of each task. For example, different mesh processing software sys- tems could be developed by different vendors, each with its own proprietary way of storing of meshes. http://www.ics.uci.edu/ ˜ eppstein http://www.ics.uci.edu/ ˜ goodrich [email protected] § [email protected] More importantly, many of the computational tasks performed on meshes are likely to slightly change their structure in places. For example, a physical simulation or animation task may introduce a “rip” in a surface or a modeler may detach a model feature (such as a hand or eyebrow), modify it to reflect a new pose, and re-attach it to the original model. In addition, models that possess significant symmetries, such as biological characters and architectural models, often have their texturing and feature mapping tasks performed on a single portion with the desire that this work be mapped to the symmetric portion(s), even if there are a few localized asymmetries to deal with during this mapping process. For the above applications, we are interested in matching pairs of quad meshes in a way that is as independent of geometric features as possible. That is, we would like matches that align the topolog- ical structure between two given quad meshes as best as possible, matching the orientations of each paired-up vertex and quad in the two meshes. Therefore, we are interested in this paper in the ap- proximate topological matching problem, which takes two given quad meshes and finds the best matching between them based on topological information alone. (See Figure 1.) Figure 1: The Approximate Topological Matching Problem. Quads in (dark) red denote mismatched regions. In spite of there being major pieces of the first mesh missing from the second, the parts of simi- larly are still matched (the two right hands actually don’t match topo- logically, as the hand of the second model is attached differently). 1.1 Prior Related Work Before presenting our results, let us review prior related work on quad meshes and mesh matching.

Upload: others

Post on 14-Mar-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

Approximate Topological Matching of Quadrilateral Meshes

David Eppstein∗

University of California, Irvine

Michael T. Goodrich†

University of California, Irvine

Ethan Kim‡

McGill University

Rasmus Tamstorf§

Walt Disney Animation Studios

ABSTRACT

We study approximate topological matching of quadrilateralmeshes, that is, the problem of finding as large a set as possibleof matching portions of two quadrilateral meshes. This study ismotivated by applications in graphics that involve shape modelingwhose results need to be merged in order to produce a final unifiedrepresentation of an object. We show that the problem of producinga maximum approximate topological match of two quad meshesin NP-hard. Given this result, which makes an exact solution ex-tremely unlikely, we show that the natural greedy algorithm de-rived from polynomial-time graph isomorphism can produce poorresults, even when it is possible to find matches with only a fewnon-matching quads. Nevertheless, we provide a “lazy-greedy” al-gorithm that is guaranteed to find good matches when mis-matchingportions of mesh are localized. Finally, we provide empirical evi-dence that this approach produces good matches between similarquad meshes.

Index Terms: F.2.2 [Analysis of Algorithms and Problem Com-plexity]: Nonnumerical Algorithms and Problems—Geometricalproblems and computations; I.3.5 [Computer Graphics]: Computa-tional Geometry and Object Modeling—Boundary representations

1 INTRODUCTION

Quadrilateral meshes represent polyhedral surfaces in such a waythat each face is a quadrilateral, which is quite useful in computergraphics applications. The usefulness of these meshes comes inpart from the fact that rectangular texture images are easily mappedwithout clipping into quadrilaterals (which we sometimes refer toas “quads”). Thus, quad meshes are desirable for surface modeling.

Quad meshes are also useful in finite element analysis, where onedesires adaptive refinement into regions of interest, since quadrilat-erals are easily partitioned into finer quadrilateral grids. Indeed,several mesh generation algorithms, such as that of Schonfeld andWeinerfelt (31) and others (1; 26; 34), begin with a coarse quadri-lateral mesh and then refine each quad of interest into a regular gridof sub-quads.

In order to best utilize the time of people working with a givenquad mesh, it is common for a single mesh to be used in a num-ber of different processing paths in parallel. For example, a singlemesh might be processed simultaneously for texture mapping, fea-ture mapping, finite-element analysis for physical simulation pur-poses, and morphing for object animation. Unfortunately, the soft-ware systems that perform the multiple simultaneous tasks on agiven mesh M often use different internal representations of M ,which in turn result in different representations of M in the outputof each task. For example, different mesh processing software sys-tems could be developed by different vendors, each with its ownproprietary way of storing of meshes.

∗http://www.ics.uci.edu/˜eppstein†http://www.ics.uci.edu/˜goodrich‡[email protected]§[email protected]

More importantly, many of the computational tasks performedon meshes are likely to slightly change their structure in places. Forexample, a physical simulation or animation task may introduce a“rip” in a surface or a modeler may detach a model feature (such asa hand or eyebrow), modify it to reflect a new pose, and re-attachit to the original model. In addition, models that possess significantsymmetries, such as biological characters and architectural models,often have their texturing and feature mapping tasks performed ona single portion with the desire that this work be mapped to thesymmetric portion(s), even if there are a few localized asymmetriesto deal with during this mapping process.

For the above applications, we are interested in matching pairs ofquad meshes in a way that is as independent of geometric featuresas possible. That is, we would like matches that align the topolog-ical structure between two given quad meshes as best as possible,matching the orientations of each paired-up vertex and quad in thetwo meshes. Therefore, we are interested in this paper in the ap-proximate topological matching problem, which takes two givenquad meshes and finds the best matching between them based ontopological information alone. (See Figure 1.)

Figure 1: The Approximate Topological Matching Problem. Quads in(dark) red denote mismatched regions. In spite of there being majorpieces of the first mesh missing from the second, the parts of simi-larly are still matched (the two right hands actually don’t match topo-logically, as the hand of the second model is attached differently).

1.1 Prior Related Work

Before presenting our results, let us review prior related work onquad meshes and mesh matching.

Page 2: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

1.1.1 Quad Mesh Generation

This is not a paper on mesh generation, but let us nevertheless men-tion some of the modeling approaches that give rise to quad meshes.There are several quad mesh generation methods that involve start-ing from a coarse quad mesh and subdividing each coarse quad intoa finer structured mesh (1; 26; 31; 34). Of course, there are alsomethods that do not create structured submeshes as a refinementstep (4; 6; 8; 28; 32). Although this is not a paper on mesh gen-eration, we note that the mesh generation process often providesus with properties we can exploit in our algorithms. For example,many mesh generation algorithms create large patches of structuredsubmeshes, each having degree 4. Such submeshes are still rela-tively common, of course, even if not directly constructed, since,by an easy argument that follows directly from Euler’s formula, thevertices in any quad mesh of bounded genus have average degreeequal to 4.

1.1.2 Mesh Compression

One tool we use in our approximate topological matching algorithmis to compress the original quad mesh so as to reduce the number ofcandidate starting points for our matching process. The problem ofmesh compression has historically been studied in the classic senseof data compression, where one wishes to produce a concise repre-sentation of a mesh for the sake of reduced transmission and storagecosts (9; 18; 20; 21; 35; 36). Our reason for using mesh compres-sion instead is based on the desire to speed up the computation timein an algorithm that operates on quad meshes. Thus, our approachactually fits the spirit of other algorithms (e.g., see (14; 15; 33; 38))that perform data compression so as to improve algorithmic perfor-mance.

1.1.3 Graph Isomorphism

In the classic graph isomorphism problem, we are given a graphG = (V, E) and a graph H = (W, F ), with |V | = |W | and |E| =|F |, and we are asked if there is a mapping f : V −→ W such thatedge e = (v, w) is an edge in E if and only if (f(v), f(w)) is anedge in F . Applied to the mesh matching problem, graph isomor-phism corresponds to the problem of finding an exact topologicalmatch, with no edges, vertices, or faces unmatched between thetwo input meshes. Much work has been done on the graph isomor-phism problem for general classes of graphs (e.g., see (10; 17; 24)),for which it is not known whether graph isomorphism can be solvedin polynomial time or if the graph isomorphism problem is NP-complete. For the special case of planar graphs, or more generallyfor models of bounded genus, isomorphism can be solved in lineartime (19; 23), but these algorithms are fairly complex.

The problem of solving graph isomorphism for meshes can besolved in polynomial time, even for models of high genus. Thereason is that, in addition to their graph structure, meshes possessstructure derived from the fact that they are embedded in manifoldsurfaces. In particular, such embeddings impose a specific, givenordering on the edges around each vertex, v, which corresponds toa clockwise or counter-clockwise listing of the edges incident to v.Thus, given a mapping of an edge in G to an edge in H , it is asimple matter to “grow out” the respective corresponding matchingbetween G and H so long as such matches are possible. That is,there is a simple O(m2) algorithm for finding an exact topologicalmatch between two m-edge meshes (or determining that no suchmatching exists)—attempt to grow out a possible match betweenG and H starting from each possible matching of edges in G to agiven edge e in H . In practical applications, such algorithms arestill too slow, however, and we address practical algorithms for thegraph isomorphism problem on quad meshes in a different paper(which is currently under submission elsewhere). Our approach inthis other paper is based on a technique that is inappropriate forsolving the approximate topological matching problem.

1.1.4 Graph Edit Distance

The approximate topological matching problem is related to theproblem of computing the edit distance between two graphs (5; 7;13; 27). The concept of graph edit distance was first introducedby Eshera and Fu (13). It involves the computation of a measureof similarity between two graphs based on the minimum numberof edit operations, such as edge insertions/deletions and vertex in-sertions/deletions, that would be needed to convert one graph intoanother, which is a problem shown to be NP-hard. Subsequent workhas focused on heuristic methods for computing graph edit distance.For example, Berretti et al. (5) describe a distance metric on graphsand apply it to content retrieval for color images, and Neuhaus andBunke (27) use automatic learning methods to compute the func-tions for graph edit distance.

The approximate topological matching is not the same as graphedit distance, however. Graph edit distance is concerned with min-imizing the number of edit operations to convert one graph to an-other, whereas approximate topological matching is concerned withmaximizing the amount of common matching quads between twoquad meshes, even if there are large portions of one of the twomeshes that might not match with any part of the other. Thus, theapproximate topological matching problem is an adaptation of themaximum common subgraph problem (22) to quad meshes, wherewe wish to match oriented quad faces as well as vertices and edges.The distinction between edit distance and approximate topologi-cal matching is important in object modeling applications, for in-stance, where one mesh could be an early version of a model, suchas a character’s face, before new facial features are added, such aseyebrows, eye lashes, and warts, and we want to match the earlierversion as best as possible against the current version. In such casesit is better to ignore the mismatching parts rather than weigh themnegatively in an edit distance value.

1.2 Our Results

In this paper, we study the approximate topological matching prob-lem for quadrilateral meshes. We show that this problem is NP-hard, implying that it is very unlikely that there is a polynomial-timealgorithm for approximate topological matching. Thus, we developa heuristic algorithm for approximate topological mesh matching,based on the use of a skeleton graph that is a well-defined, robustsubgraph of the mesh. This skeleton is then used to identify an-chors to begin a matching process similar to the way the medialaxis is visualized for a polygon (e.g., see (11; 29)). If we imaginethat the plane is made of a combustible material and we start a firestarting from each boundary edge of the polygon, then the medialaxis is defined by the places where two waves of fire meet. In ourcase, we apply this approach to quad meshes, viewing the quadsas “combustible material” and the anchors as the starting points forour fires. We grow regions in the two input meshes simultaneously,matching similar topological substructures as we go.

Such a fire-propagation approach to matching the two inputmeshes has an unfortunate complication, however. Namely, if weuse the natural greedy approach to propagate matching portions ofthe wavefront, then this process can lead to poor matches. In partic-ular, we show that even if one small portion of one mesh is shrunkrelative to a portion in the other, this greedy algorithm can produceglobally poor matches. Nevertheless, we show that our fire-growingapproach to approximate matching can be made to work effectivelyeven in these cases, by growing the wavefronts in a “lazy-greedy”fashion. In addition, we provide experimental results that showthat the lazy-greedy algorithm can produce good matches quicklyin practice.

2 PRELIMINARIES

Before we discuss our results, let us give some preliminary defini-tions and observations about quadrilateral meshes.

Page 3: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

2.1 The Topology of Quad Meshes

Any graph drawn on the sphere S0 in three-dimensional space par-titions the surface of S0 into cells such that each is homeomorphicto a disk (we will always assume in this paper that graphs are drawnwithout edge crossings). Each such cell is called a face in the em-bedding. Adding g “handles” to S0 gives the surface Sg , which issaid to have genus g. For example, a traditional coffee cup is ofgenus 1. Likewise, the dog toy shown in Figure 2 has genus 16.

Figure 2: A dog toy, which has genus 16.

A cellular embedding of a graph on Sg is a drawing that parti-tions Sg into cells such that each is homeomorphic to a disk. Wedefine a quadrilateral mesh to be a cellular embedding of a graphG = (V, E) onto a surface Sg such that each face is a quadrilateral.We say that the genus of the mesh is g in this case. We thereforeview a quad mesh as a triple (V, E, Q) where V is a set of vertices,E is a set of edges, and Q is a set of quadrilaterals. In addition,we assume that quad meshes are represented with a data structure,like the “winged edge” structure (3), that supports the followingoperations:

• List the incident edges around a given vertex (in clockwise orcounter-clockwise order) in time proportional to the degree ofthat vertex.

• List the bounding edges around a given face (in clockwise orcounter-clockwise order) in time proportional to the size ofthat face.

• List the two vertices that are the endpoints of a given edge inconstant time.

The simplest form of quad mesh is a structured mesh, where everyvertex has degree four. The average degree of vertices in a bounded-genus quad mesh is 4, and it is common for the majority of verticesin a quad mesh to have degree 4. For this reason, if a vertex ina quad mesh is an interior vertex with degree different than 4, oran exterior (boundary) vertex with degree different than 3, then werefer to that vertex as an extraordinary vertex.

2.2 The Size of a Quad Mesh

Traditionally, an algorithm operating on a graph G is characterizedin terms of n = |V |, the number of vertices of G, and m = |E|,the number of edges in G. We have these measures in quad meshalgorithms as well, but we also have q = |Q|, the number of quads,so it is useful to relate these quantities.

Observation 1 In a quad mesh with m edges and q faces, 2q ≤m ≤ 4q.

Proof: If we sum up the number of edges on every face we willcount each edge at least once and at most twice. Since each face isa quadrilateral, 4q ≤ 2m and m ≤ 4q.

Observation 2 The number of edges and faces in a quad mesh canbe arbitrarily larger than the number of vertices.

Proof: We can place two vertices at opposite poles of a sphereand add as many edges as we like joining them. Now remove thesphere and enlarge each edge to be a thin tube. Next, take eachoriginal vertex and split into two points separated by the width of atube, with one on top and one on the bottom. This creates a shapesimilar to the dog toy shown in Figure 2. Now, for each tube, runan edge between the two top vertices, an edge between the twobottom vertices, and an edge joining top to bottom at each pole.This creates a quad mesh with four vertices and an arbitrary numberof faces and edges.

Although it is not uncommon in the solid modeling literature toallow for such multiple edges and even self loops in the graph de-fined by a quadrilateral mesh, we will restrict ourselves in this pa-per to simple meshes, where there disallow multiple edges betweenthe same pair of vertices and we disallow self loops. Likewise, wedisallow multiple edges and self loops in the dual graph, which isformed by placing a vertex in each quad and joining two quads Qand R with an edge any time Q and R have an edge of the meshin common. Likewise, we require that the mesh be well-formed,meaning that it satisfy the following:

1. For each vertex v, the set of quads containing v is connectedin the dual graph.

2. The boundary of a quadrilateral mesh M consists of all edgesof E that belong to exactly one quadrilateral in M and all ver-tices incident to an edge of this type. For every cyclic portionC of the boundary of M on Sg (that is, a “hole” in the mesh),the interior of C is homeomorphic to a disk. That is, each holein M is contractible.

3. Every edge in M is adjacent to at least one and and at mosttwo quadrilateral faces of M .

4. Any two quadrilaterals in Q intersect in a single edge, a singlevertex, or the empty set.

Observation 3 In a simple, connected, well-formed quadrilateralmesh M of genus g, with n vertices and m edges,

m ≤ 2n + 4g − 4.

Proof: Since M is a simple, cellularly-embedded graph in Sg , theEuler characteristic implies that

n − m + q = 2 − 2g.

Specifically, the Euler characteristic (which is also called “Euler’sformula” or the “Euler-Poincare characteristic”) states that, in suchembeddings, the number of vertices minus the number of edges plusthe number of faces is equal to 2 − 2g. That is, in our case, m =n+q+2g−2. By Observation 1, q ≤ m/2. Thus, m ≤ 2n+4g−4.

In almost all practical applications of quadrilateral meshes, thegenus g of a given mesh is bounded by constant and it is almost cer-tainly O(n). In fact, g is typically 0 or 1. Thus, the above lemmaimplies that in almost every practical application using a mesh Mwith n vertices and m edges, m is O(n). Thus, for example, thetime complexity of the simple wave-growing exact graph isomor-phism algorithm on such meshes is O(n2). We also have the fol-lowing.

Lemma 4 In a simple, connected, well-formed quadrilateral meshM of genus g, with n vertices and m edges,

m ≤ (

r

4

3g + 2)n − 4.

Page 4: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

Proof: The proof follows that of a similar lemma of Wood andTelle (37), but is adapted to quad meshes. From Observation 3, weknow that

m ≤ 2n + 4g − 4.

So we need to show that 4g ≤“q

4

3g

n. That is, we need to show

g ≤ n2/12. This follows from the fact that M is simple and thecomplete graph on n vertices, Kn, has genus at most n2/12 (e.g.,see (25)).

3 ON THE DIFFICULTY OF APPROXIMATE TOPOLOGICAL

MATCHING

As mentioned above, the problem of finding a best approximatetopological match between two quad meshes has several uses inobject representation and rendering applications. Unfortunately, aswe show in this section, the problem of finding an optimal approx-imate topological match is NP-hard.

In order to be precise, let us formalize the approximate topo-logical matching problem for quad meshes. Suppose we are giventwo quadrilateral meshes, M1 and M2. A matching submesh S1 ofM1, with respect to M2, is a connected set of quads in M1 that ismapped one-to-one to a connected set of quads in M2 by a functionµ that maps quads in S1 to quads in M2 such that q1 and q2 areadjacent in S1 if and only if µ(q1) and µ(q2) are adjacent in M2

(using adjacency across edge boundaries). The approximate topo-logical matching problem is to find a matching submesh S1 of M1,with respect to M2, and corresponding mapping function µ, suchthat S1 has the largest number of quads over all such submeshes.Unfortunately, we have the following.

Theorem 5 The approximate topological matching problem forquad meshes is NP-hard.

Proof: We will give a reduction from the known NP-completeproblem of determining if a given cubic planar graph is Hamilto-nian (16). Suppose then that we are given an n-vertex cubic planargraph G as input, that is, a graph G that has degree 3 and whichcan be drawn in the plane without crossings. Our proof is basedon showing that we can construct two meshes M1 and M2 in poly-nomial time such that all but n quads of M1 can be matched withpart of M2 if and only if G is Hamiltonian, that is, G contains asa cycle that visits each vertex in G exactly once. We begin ourconstruction by using any existing polynomial-time method (e.g.,see (2; 12; 30)) to produce an embedding of G in an O(n) × O(n)integer grid, where n is the number of vertices in G. This embed-ding allows us to associate integer coordinates in the plane to thevertices of G, from which we will build a quad mesh, M2. Beforewe perform this construction, however, let us first build the meshM1 that we want to match completely to M2.

In particular, let C be a simple cycle with n vertices, say, embed-ded at regular intervals around the boundary of a sufficiently largecircle in the plane (separate from the grid G is embedded in). Weconstruct a mesh M1 from C by expanding each edge of C into aconnected sequence of four quads, linked in a “chain,” and expand-ing each vertex of C according to the replacement submesh of fourquads shown in Figure 3a. That is, if we have an edge (u, v) in Cconnecting u to v that is followed by an edge (v, w), we replace(u, v) by a chain of four quads that connect to v’s four quads asin the lower-right part of Figure 3a and we have the chain of fourquads for (v, w) connect as in the upper-left part of Figure 3a.

We convert G into a second quad mesh M2 by expanding eachedge into a chain of four quads, as in our construction of M1, butwe connect them to vertices in a different way. Specifically, eachvertex in G has degree 3, so we instead connect each edge chain offour quads according to the replacement mesh shown in Figure 3b.

(a)

(b)

Figure 3: Gadgets used to prove that approximate topological match-ing is NP-hard: (a) the vertex replacement submesh for C, (b) thevertex replacement submesh for G.

The dashed lines in the figure show all the possible ways that a max-imum number of quads in a vertex submesh from M1 can match amaximum number of quads in the vertex submesh in M2. Namely,a vertex submesh of 4 quads in M1 can match at most 3 quads ina vertex submesh M2. That is, all but one of the quads in a ver-tex submesh of M1 can match in a vertex submesh of M2. Also,note that the same cannot be said of the submeshes of M1 associ-ated with edges of C. Namely, note that since each edge in C isexpanded into a connected chain of 4 quads, the quads in an edgesubmesh of M1 can match at most 2 quads in a vertex submesh ofM2. In other words, to get the largest number of matching quadsbetween M1 and M2, we need to match vertex submeshes in M1 tovertex submeshes in M2.

So we have yet to show that G is Hamiltonian if and only ifall but n of the quads in M1 can be matched with quads in M2.Suppose that G is Hamiltonian. That is, C is a subgraph of G;hence, we can match each vertex submesh of M1 with a vertexsubmesh of M2, using the cycle C as a guide on how to similarlymatch each edge submesh of M1 with an edge submesh of M2,again, using the embedding of C in G as a guide. Then there is atopological match of M1 in M2 that pairs up all but n quads fromM1, i.e., the number of matched quads between M1 and M2 is 7n.

Suppose, on the other hand, that there is a match of M1 and M2

that matches 7n quads, that is, all but n quads from M1. As we havenoted above, the only way this can occur is if the edge submeshesof M1 match edge submeshes of M2 and 3 quads in each vertexsubmesh of M1 match inside a vertex submesh of M2. Thus, C is asubgraph of G, that is, G is Hamiltonian. This completes the proof.

Page 5: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

4 OUR ALGORITHM

Given that the approximate topological matching problem is NP-hard, it is very unlikely that there is an efficient algorithm for solv-ing it exactly. Thus, let us discuss a heuristic approach.

4.1 Identifying Anchors

Let us begin with the starting point for our heuristic algorithm—theidentification of good anchors that can seed the process of matchingpairs of quads in the input meshes M1 and M2. That is, extraordi-nary vertices in M1 and M2 that have relatively distinctive neigh-borhoods. Note: if there are no extraordinary vertices at all (e.g., ifM1 and M2 are tori), then we pick an arbitrary pair of vertices inM1 and M2 as anchors.

In order to find a good set of anchors in the general case, weapply a few iterations of the Weisfeiler and Leman (WL) algorithmfor exact graph isomorphism (e.g., see (17)). Recall that in the WLalgorithm, we initially label each vertex with a label associated withits degree1. Then, each vertex is labeled by a string of its neighbors’labels in an order that appears in the topological embedding. Inturning the cyclic ordering into a linear ordering, we pick the onethat is lexicographically minimum. Then we let these strings bethe new labels of the vertices (which we can re-normalize to be theintegers from 1 to n with a simple radix sort). Algorithm 1 givesa pseudocode for this procedure, which views the vertex labels as“colors.”

foreach vertex u ∈ M dotmpColor[u] = deg(u);

endforeach u ∈ M do

Color[u] = ();foreach v ∈ neighbor(u) do

Color[u] = Color[u] + tmpColor[v];endColor[u]= Lexicographical minimum ordering ofColor[u];

endreturn the set of vertices with unique color label;

Algorithm 1: Algorithm for ColorGraph

Observe that the second loop in Algorithm 1 can be repeated torefine the color labels of vertices. This repetition should be doneuntil a reasonable stopping condition is reached. For example, weused the stopping condition of repeating until we reach a set up-per bound, k, on the number of iterations or until at least one pairof uniquely labeled vertices are found, one from each mesh. If werepeat this loop i times, the label of each vertex u will contain in-formation about the vertices that are within distance i from u. Therunning time of this second loop is 2m = O(m), which is O(n)in the case of planar meshes or meshes of at most linear genus, byObservation 3.

The final step of the algorithm for identifying seeds to initiatemesh-matching growth from is that of finding corresponding an-chors from the labeled compressed meshes. In order to find suchseeds, we first match the rarest (hopefully unique) labeled verticesreturned from the two compressed meshes, and then look for match-ing neighbors of the two matched vertices. Again, for most meshes,this process takes O(n) time in the worst case, by Observation 3 orLemma 4.

1 Not only the degree of each vertex can serve as the seed for labels,

we may also choose to use the edge weights in the compressed meshes. In

order to do so, we can label each edge by number of edges contracted while

compressing the meshes.

4.2 Skeleton Graphs

As noted above, we are interested in finding rare or even uniquely-labeled anchors, so as to limit the number of possible candidatestarting points for growing matching sets of quads between the twoinput meshes. Thus, it makes intuitive sense that we should concen-trate on extraordinary vertices. In order to focus on the adjacenciesbetween these vertices, we apply a compression scheme that fo-cuses on extraordinary vertices and in most cases reduces the sizeof the graph we must deal with.

4.3 Particle Shooting

The idea for constructing this compressed skeleton graph insideeach mesh is quite simple: we imagine that we shoot a particle outalong every possible edge going out of each extraordinary vertex.These particles travel separately along the edges going out fromextraordinary vertices. When a particle enters a normal vertex itcontinues through that vertex and leaves out the opposite side (un-less this is a boundary vertex and there is no edge on the other side).In propagating these fictitious particles in this way we trace out asubgraph in each input mesh, M1 and M2. We let the particlescontinue to move, tracing out the compressed graph we are goingto use for color label assignment, until each such particle reachesanother extraordinary vertex (which is a very common occurrencegiven the way that people build quad meshes in practice) or the par-ticle reaches a boundary edge. We then perform our anchor-findingprocedure on this skeleton graph. (See Figure 4.)

start

Figure 4: Anchor finding in a simple quad mesh, M1. This meshhas five extraordinary vertices, consisting of the four corners and thevertex marked “start.” The vertex marked “start” is the best candidatefor an anchor in this mesh, since the neighborhood structure of theother four extraordinary vertices are similar to each another. Theedges traversed in the “particle-shooting” process are shown bold.

Page 6: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

4.4 A False Start: The Greedy Algorithm

Given a set of anchors to begin our matching process, perhaps themost natural heuristic algorithm for solving the approximate topo-logical matching problem is to start with a seed pair of matchingquads, starting at some candidate anchors, and grow out matchingmeshes from this starting point.

The natural greedy algorithm based on this approach would beto grow out the matching set of quads in waves, adding as manyquads as possible so as to satisfy the adjacency constraint for quads(e.g., by restricting our attention to quads that are adjacent across anedge or vertex). Unfortunately, this greedy approach suffers from aserious drawback, which is highlighted by a simple example.

Suppose we are given two similar meshes, M1 and M2, as, forexample, shown in Figures 4 and 5, such that M2 is an exact matchfor M1 except that some small group of quads in M2 is compressedinto a set of edges.

start

Figure 5: A candidate quad mesh, M2. Note that M2 is an exactmatch for the quad mesh M1 from 4 except that three quads in themiddle are compressed into individual edges in M2.

Suppose further that we grow out sets of matching quads in M1

and M2 starting from some anchor point, using the greedy ap-proach of matching as many quads as possible with each wavefrontpropagation. When this propagating wavefront reaches the set ofcompressed quads, it will correctly match long sets of quads oneach side of the mis-matching portion. But it will also incorrectlymatch as many quads as possible across the compressed edges aswell. Unfortunately, this sets off a cascading failure, as the wave-front that propagated across the compressed quads will be out ofphase with the (correct) sets of quads that are being matched asthey go around the compressed region. The cascade continues be-cause the incorrectly-matched quads are being “grown” ahead ofthe correctly-matching quads. The correctly-matching quads neverhave a chance to “catch up” to this wave, however, and it can con-tinue cascading across the entire mesh. This unfortunate growthpattern is illustrated for the meshes M1 and M2 of Figures 4 and 5in Figure 6.

Thus, we do not recommend that the greedy algorithm be used asa heuristic for solving the approximate topological matching prob-lem. Instead, we advocate the use of a lazy-greedy approach.

start

Figure 6: An unfortunate cascading failure in M2 caused by thegreedy mesh growing algorithm applied to the meshes of Figures 4and 5.

4.5 The Lazy-Greedy Algorithm

In this section, we discuss our lazy-greedy approach to solving theapproximate topological matching problem for two quad meshes byusing a wavefront “fire-propagation” method.

4.5.1 The Main Idea Behind our Matching Algorithm

The main idea behind this oxymoronic algorithm is to grow outwaves of matching quads, as in the greedy algorithm given aboveas a false start, but to do so in a more relaxed way that helps toavoid the cascading failures that can arise from the straightforwardgreedy algorithm.

Let us assume that we have done an initial color labeling andhave found a set of anchors to begin the matching process from inM1 and M2. The goal of the lazy-greedy algorithm is to incre-mentally build a mapping function, µ, that matches quads in M1 toquads in M2. Initially, µ maps the two anchor quads in M1 and M2

to each other (defining an edge in the dual graph). As we proceed,we track of the set of quads where we can expand the matchingfunction µ to more quads. Let S be the set of currently matchedquads, that is, each quad q in M1 for which we have determineda matching quad, µ(q). Since we start matching from a seed, ateach iteration, S forms a contiguous block of quads in M1 with acorresponding set of matching quads, µ(S) in M2. Now, let S′ bea subset of quads in S on the boundary of the contiguous submeshS, that is, quads that have adjacent unmatched neighbors. Whengrowing the match at each iteration, note that we only need to con-sider quads that are either vertex or edge adjacent to quads in S′ orµ(S′), since the quads that are interior to the contiguous block haveno adjacent unmatched quads.

4.5.2 Using a Compatibility Graph for Growing MatchingSubmeshes

Let A be the set of unmatched quads in M1 that are vertex or edgeadjacent to quads in S′, and let B be the set of unmatched quadsin M2 that are vertex or edge adjacent to quads in µ(S′). For eachquad q in A, let M(q) be the set of quads in B that could match

Page 7: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

with q, that is, we include in M(q) each quad r in B such that r isadjacent to a quad µ(t) with q being adjacent to t in the same way asr and µ(t) (i.e., across a corresponding vertex or edge adjacency).

Let us create a compatibility graph L by defining, for eachM(q), a vertex vi,q for each quad in M(q). Note that same quad inB might be listed in different M(q) sets, in which case we createa different vertex in L for each copy of that quad in the differentM(q) sets. We say that a vertex vi,q is adjacent to vertex vi,s in Lif

• q and s are adjacent across an edge in M1.

• The quads, r and t in M2, corresponding respectively to vi,q

and vi,s are compatible in M2, meaning that if we were toextend µ by mapping q to r and s to t, then the submesh in M1

consisting of q and s and all their adjacent quads in S′ wouldbe consistent (in the topological sense) with the submesh inM2 consisting of r and t and all their adjacent quads in µ(S′).

Note that the graph L consists of paths, isolated vertices, or a cycle,i.e., vertices in L have degree at most 2.

4.5.3 The Lazy-Greedy Heuristic

The lazy-greedy heuristic is to extend µ in each iteration by addingthe matches defined by a largest connected component (i.e., pathor cycle) in L. Note that this is a greedy algorithm in the sensethat it is augmenting our match using an optimization criterion thatmaximizes an objective function. But it is also a lazy algorithmin that it postpones performing a lot of potentially valid matchesbetween quads in M1 and M2 just because they didn’t belong tothe largest connected component in the compatibility graph L. Werepeat this lazy-greedy heuristic process until the current version ofL contains no vertices. (See Figure 7.)

Figure 7: The lazy-greedy algorithm. The shaded (blue) regions col-lectively denote S′, the currently matched quads. The labeled quadsin both meshes correspond to the pairs of quads that share the sameadjacent quads in S′. Finally, we show the compatibility graph L con-structed from the quads adjacent to S′. Since quads 4,5 and 6 formthe largest connected component in L, we match these quads at thisiteration.

The benefit of the lazy-greedy approach is that it allows ourmatching process to match the quads around a small mismatch-ing region even when the mismatch is caused by a compression of

quads into individual edges. Such a compression causes the greedyalgorithm to immediately march through these bad regions, whereasthe lazy-greedy algorithm will only venture into such regions as alast resort. We illustrate the difference this approach makes for themeshes M1 and M2 of Figures 4 and 5 in Figure 8.

start

Figure 8: An isolation of a small mismatching region in M2, show-ing how the lazy-greedy algorithm avoids the unfortunate cascadingfailure caused by the greedy mesh growing algorithm applied to themeshes of Figures 4 and 5.

5 EXPERIMENTAL RESULTS

We have implemented our algorithm and have empirically tested thetwo main claims of our approach on real-world quad meshes fromthe character database at Walt Disney Animation Studios. The firstclaim that we tested is the following:

• The skeleton graph constructed by our algorithm significantlycompresses quad meshes in a way that preserves essential fea-tures.

Table 1 gives an overview of the size of skeleton graphs for anumber of the models in the Disney character database.

Model Original mesh Skeleton graph Reduction

vertices edges vertices edges (%)

bear 1070 2110 202 393 81%

chic 932 1827 32 56 97%

shirt 3099 6134 518 1015 83%

director 9958 19889 2510 5001 75%

tommy 10281 20530 2496 4973 76%

body 13238 26457 3176 6339 76%

girl 6976 13903 2340 4647 66%

Table 1: Sizes of skeleton graphs for various quad mesh models.

Note that the reduction percentages average around 75%. Themain point of this compression is not for storage savings, how-ever, although it could be used for this purpose, since the regionsbounded by edges of the skeleton graph are all structured meshes.Instead, we use the skeleton graph to drive our approximate match-ing process.

Page 8: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

Another claim of our method is the following:

• The lazy-greedy algorithm runs fast enough for interactivemodeling purposes.

The running times for our matching process, applied to the samecharacters as used for skeleton graph computations are shown inTable 2. The second meshes in these cases correspond to similarmodels (e.g., two bears), alternate poses, and across symmetries(e.g., in a shirt).

Model Mesh size Time

vertices edges seconds

bear 1070 2110 0.04

chic 932 1827 0.02

shirt 3099 6134 0.12

director 9958 19889 0.72

tommy 10281 20530 0.76

body 13238 26457 1.08

girl 6976 13903 0.65

Table 2: Running times for approximate topological matching of vari-ous quad mesh models.

Note that all the running times for approximate matching are ata second or less. This is certainly sufficient for interactive model-ing purposes. Moreover, it significantly speeds up what used to bea semi-automated process that involved human input of a pair ofedges to use as anchors.

Finally, we also make the following claim for our algorithm:

• The lazy-greedy algorithm finds good approximate matches.

Naturally, since we are not aware of any other approximate topo-logical matching algorithms, testing this claim against other algo-rithms is not possible. Nevertheless, we can prove that our algo-rithm is successful in many cases. Suppose, for example, that thereis a mapping between two simple, connected, well-formed quadmeshes M1 and M2 such that each connected mismatched regionhas boundary complexity of at most δ. Suppose further that themedial axis of the matched region for M1 and M2 is connected andhas a spanning tree T such that each edge of T has a cross-sectionalwidth of at least ǫ > 2δ. Then our algorithm will succeed in findinga match at least as good as this match.

In addition, a subjective evaluation of the matches our algorithmproduced on the Disney character database demonstrated that ouralgorithm empirically found good matches. For example, we showthe quality of the matches produced by our algorithm on the bearsand girl models in Figures 9 and 10. In addition, an animation ofour algorithm is available for download at the following location:

www.ics.uci.edu/˜eppstein/projects/firefront.mov

6 CONCLUSION AND FUTURE DIRECTIONS

In this paper, we study the approximate topological matching prob-lem for quad meshes, showing this problem is NP-hard in general.Nevertheless, we provide an efficient heuristic algorithm that workswell in practice and provably well for a large class of models that iscommon in practice.

Directions for future work include the following:

• Our methods are directed at connected models. How hard isit to extend the lazy-greedy algorithm to handle disconnectedmodels?

• Our methods find a single connected region of matchingquads. Is there a way to generalize the lazy-greedy approachto handle disconnected matching regions in a way that main-tains distance and intuitive correspondence as much as possi-ble?

Figure 9: Approximate Matching; quads in (dark) red denote mis-matched regions. Only the ears, which are indeed topologically dif-ferent, were not matched.

Figure 10: An Approximate Matching Result; quads in (dark) reddenote mismatched regions. This example shows how the lazy-greedy algorithm tolerates both modest mis-matches and massivemis-matches, as in Figure 1, unlike approaches based on minimizingedit distance. (The two right hands actually don’t match topologically,as the hand of the second model is attached differently.)

Page 9: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

Acknowledgments

This research was done, in part, while the first two authors wereconsultants for Walt Disney Animation Studios. Likewise, this re-search was done, in part, while the third author was a summer internfor Walt Disney Animation Studios.

REFERENCES

[1] C. G. Armstrong, D. J. Robinson, R. M. McKeag, T. S. Li,S. J. Bridgett, and R. J. Donaghy. Applications of the medialaxis transform in analysis modelling. In NAFEMS, Proc. 5thInt. Conf. Reliability of FEM for Engineering Applications,pages 415–426, 1995.

[2] G. D. Battista, P. Eades, R. Tamassia, and I. G. Tollis. GraphDrawing: Algorithms for the Visualization of Graphs.Prentice Hall PTR, Upper Saddle River, NJ, USA, 1998.

[3] B. G. Baumgart. Winged edge polyhedron representation.Technical Report CS-TR-72-320, Stanford University, 1972.

[4] M. W. Bern and D. Eppstein. Quadrilateral meshing by circlepacking. Int. J. Computational Geometry and Applications,10(4):347–360, 2000.

[5] S. Berretti, A. D. Bimbo, and P. Pala. A graph edit distancebased on node merging. In Image and Video Retrieval,volume 3115 of Lecture Notes in Computer Science, pages464–472, 2004.

[6] T. D. Blacker and M. B. Stephenson. Paving: a newapproach to automated quadrilateral mesh generation. Int. J.Numerical Methods in Engineering, 32:811–847, 1991.

[7] H. Bunke. On a relation between graph edit distance andmaximum common subgraph. Pattern Recognition Letters,18(8):689–694, 1997.

[8] S.-W. Chae and J.-H. Jeong. Unstructured surface meshingusing operators. In Proc. 6th Int. Meshing Roundtable, pages281–291, 1997.

[9] D. Cohen-Or, D. Levin, and O. Remez. Progressivecompression of arbitrary triangular meshes. In Proc. 10thIEEE Visualization (VIS ’99), page 11, 1999.

[10] D. G. Corneil and C. C. Gotlieb. An efficient algorithm forgraph isomorphism. J. ACM, 17(1):51–64, 1970.

[11] M. de Berg, M. van Kreveld, M. Overmars, andO. Schwarzkopf. Computational Geometry: Algorithms andApplications. Springer-Verlag, Berlin, Germany, 2nd edition,2000.

[12] H. de Fraysseix, J. Pach, and R. Pollack. Small setssupporting fary embeddings of planar graphs. In STOC ’88:Proceedings of the twentieth annual ACM symposium onTheory of computing, pages 426–433, New York, NY, USA,1988. ACM Press.

[13] M. A. Eshera and K. S. Fu. An image understanding systemusing attributed symbolic representation and inexactgraph-matching. IEEE Trans. Pattern Anal. Mach. Intell.,8(5):604–618, 1986.

[14] T. Feder and R. Motwani. Clique partitions, graphcompression and speeding-up algorithms. In Proc. 23rdACM Symp. Theory of Computing, pages 123–133, 1991.

[15] P. Ferragina and G. Manzini. Opportunistic data structureswith applications. In Proc. 41st Symp. Foundations ofComputer Science, pages 390–398, 2000.

[16] M. R. Garey and D. S. Johnson. Computers andIntractability: A Guide to the Theory of NP-Completeness.W. H. Freeman, 1979.

[17] M. Grohe. Isomorphism testing for embeddable graphsthrough definability. In STOC ’00: Proceedings of thethirty-second annual ACM symposium on Theory ofcomputing, pages 63–72, New York, NY, USA, 2000. ACMPress.

[18] S. Gurnhold and W. Strasser. Real time compression oftriangle mesh connectivity. In Proc. 25th Conf. ComputerGraphics and Interactive Technology, pages 133–140, 1998.

[19] J. E. Hopcroft and J. K. Wong. Linear time algorithm forisomorphism of planar graphs. In Proc. 6th ACM Symp.Theory of Computing, pages 172–184, 1974.

[20] A. Khodakovsky, P. Alliez, M. Desbrun, and P. Schroder.Near-optimal connectivity encoding of 2-manifold polygonmeshes. Graph. Models, 64(3/4):147–168, 2002.

[21] D. King, J. Rossignac, and A. Szymczak. Connectivitycompression for irregular quadrilateral meshes. TechnicalReport GIT-GVU-99-36, Georgia Institute of Technology,1999.

[22] S. Marini, M. Spagnuolo, and B. Falcidieno. From exact toapproximate maximum common subgraph. In Graph-BasedRepresentations in Pattern Recognition, pages 263–272.Springer-Verlag, Lecture Notes in Computer Science 3434,2005.

[23] G. Miller. Isomorphism testing for graphs of bounded genus.In Proc. 12th ACM Symp. Theory of Computing, pages225–235, 1980.

[24] G. L. Miller. Graph isomorphism, general remarks. In STOC’77: Proceedings of the ninth annual ACM symposium onTheory of computing, pages 143–150, New York, NY, USA,1977. ACM Press.

[25] B. Mohar and C. Thomassen. Graphs on Surfaces. JohnsHopkins University Press, 2001.

[26] M. Muller-Hannemann. High quality quadrilateral surfacemeshing without template restrictions: a new approach basedon network flow techniques. In Proc. 6th Int. MeshingRoundtable, pages 293–307, 1997.

[27] N. Neuhaus and H. Bunke. Automatic learning of costfunctions for graph edit distance. Information Science,177(1):239–247, 2007.

[28] D. Nowottny. Quadrilateral mesh generation viageometrically optimized domain decomposition. In Proc. 6thInt. Meshing Roundtable, pages 309–320, 1997.

[29] F. P. Preparata and M. I. Shamos. Computational Geometry:An Introduction. Springer-Verlag, New York, NY, 1985.

[30] W. Schnyder. Embedding planar graphs on the grid. In SODA’90: Proceedings of the first annual ACM-SIAM symposiumon Discrete algorithms, pages 138–148, Philadelphia, PA,USA, 1990. Society for Industrial and Applied Mathematics.

Page 10: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

[31] T. Schonfeld and P. E. R. Weinerfelt. The automaticgeneration of quadrilateral multi-block grids by theadvancing front technique. In Numerical grid generation incomputational fluid dynamics and related fields; Proceedingsof the 3rd International Conference, Barcelona, Spain, pages743–754, 1991.

[32] K. Shimada, J.-H. Liao, and T. Itoh. Quadrilateral meshingwith directionality control through the packing of squarecells. In Proc. 7th Int. Meshing Roundtable, pages 61–75,1998.

[33] B. C. Smith and L. A. Rowe. Algorithms for manipulatingcompressed images. Computer Graphics and Applications,13(5):34–42, 1993.

[34] J. A. Talbert and A. R. Parkinson. Development of anautomatic two-dimensional finite element mesh generatorusing quadrilateral elements and Bezier curve boundarydefinition. Int. J. Numerical Methods in Engineering,29:1551–1567, 1991.

[35] G. Taubin and J. Rossignac. Geometric compression throughtopological surgery. ACM Trans. Graphics, 17(2):84–115,1998.

[36] C. Touma and G. C. Triangle mesh compression. In Proc.Graphics Interface, pages 26–34, 1998.

[37] D. R. Wood and J. A. Telle. Planar decompositions and thecrossing number of graphs with an excluded minor. NewYork Journal of Mathematics, 13:117–146, 2007.

[38] B.-L. Yeo and B. Liu. Rapid scene analysis on compressedvideo. IEEE Trans. Circuits and Systems for VideoTechnology, 5(6):533–544, 1995.

Page 11: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

Vis Comput (2009) 25: 771–783DOI 10.1007/s00371-009-0363-z

O R I G I NA L A RT I C L E

Approximate topological matching of quad meshes

David Eppstein · Michael T. Goodrich · Ethan Kim ·Rasmus Tamstorf

Published online: 16 April 2009© Springer-Verlag 2009

Abstract In this paper, we study the problem of approxi-mate topological matching for quadrilateral meshes, that is,the problem of finding as large a set as possible of match-ing portions of two quadrilateral meshes. This study is mo-tivated by applications in graphics that involve the modelingof different shapes that have results needing to be mergedin order to produce a final unified representation of an ob-ject. We show that the problem of producing a maximum ap-proximate topological match of two quad meshes is NP-hardand that its decision version is NP-complete. Given theseresults, which make an exact solution extremely unlikely,we show that the natural greedy algorithm derived frompolynomial-time graph isomorphism can produce poor re-sults, even when it is possible to find matches with only afew nonmatching quads. Nevertheless, we provide a “lazy-greedy” algorithm that is guaranteed to find good matcheswhen mismatching portions of mesh are localized. Finally,we provide empirical evidence that this approach producesgood matches between similar quad meshes.

D. Eppstein · M.T. Goodrich (�)Dept. of Computer Science, Univ. of California, Irvine,CA 92697-3435, USAe-mail: [email protected]: http://www.ics.uci.edu/~eppsteinurl: http://www.ics.uci.edu/~goodrich

E. KimSchool of Computer Science, McGill University, Montreal,Quebec, Canada H3A 2A7e-mail: [email protected]

R. TamstorfWalt Disney Animation Studios, 500 S. Buena Vista St., Burbank,CA 91521, USAe-mail: [email protected]

Keywords Quad mesh · Topological matching · NP-hard ·NP-complete · Lazy-greedy heuristic · Isomorphism

1 Introduction

Quadrilateral meshes represent polyhedral surfaces in sucha way that each face is a quadrilateral, which is quite usefulin computer graphics applications. The usefulness of thesemeshes comes in part from the fact that rectangular textureimages are easily mapped without clipping into quadrilater-als (which we sometimes refer to as “quads”). Thus, quadmeshes are desirable for surface modeling.

Quad meshes are also useful in finite-element analysis,where one desires adaptive refinement into regions of in-terest, since quadrilaterals are easily partitioned into finerquadrilateral grids. Indeed, several mesh generation algo-rithms, such as that of Schonfeld and Weinerfelt [37] andothers [2, 30, 40], begin with a coarse quadrilateral meshand then refine each quad of interest into a regular grid ofsub-quads.

In order to best utilize the time of people working witha given quad mesh, it is common for a single mesh to beused in a number of different processing paths in parallel.For example, a single mesh might be processed simultane-ously for texture mapping, feature mapping, finite-elementanalysis for physical simulation purposes, and morphing forobject animation. Unfortunately, the software systems thatperform multiple simultaneous tasks on a given mesh M of-ten use different internal representations of M , which in turnresult in different representations of M in the output of eachtask. For example, different mesh processing software sys-tems could be developed by different vendors, each with itsown proprietary way of storing of meshes.

Page 12: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

772 D. Eppstein et al.

Fig. 1 Illustrating the symmetry in anthropomorphic models. Beingable to approximately match the left and right sides of these modelscan speed up painting and animation tasks. Note that these models havesimilar, but not exact, left-right reflective symmetry

More importantly, many of the computational tasks per-formed on meshes are likely to slightly change their struc-ture in places. For example, a physical simulation or anima-tion task may introduce a “rip” in a surface, or a modelermay detach a model feature (such as a hand or eyebrow),modify it to reflect a new pose, and reattach it to the originalmodel. In addition, models that possess significant symme-tries, such as biological characters and architectural models,often have their texturing and feature mapping tasks per-formed on a single portion with the desire that this workbe mapped to the symmetric portion(s), even if there are afew localized asymmetries to deal with during this mappingprocess. (See Fig. 1.)

For the above applications, we are interested in matchingpairs of quad meshes in a way that is as independent of geo-metric features as possible. That is, we would like matchesthat align the topological structure between two given quadmeshes as best as possible, matching the orientations of eachpaired-up vertex and quad in the two meshes. Therefore, weare interested in this paper in the approximate topologicalmatching problem, which takes two given quad meshes andfinds the best matching between them based on topologicalinformation alone. (See Fig. 2.)

1.1 Prior related work

Before presenting our results, let us review prior relatedwork on quad meshes and mesh matching.

1.1.1 Quad mesh generation and remeshing

This is not a paper on mesh generation, but let us never-theless mention some of the modeling approaches that giverise to quad meshes. There are several quad mesh generationmethods that involve starting from a coarse quad mesh andsubdividing each coarse quad into a finer structured mesh[2, 30, 37, 40]. Of course, there are also methods that do notcreate structured submeshes as a refinement step [5, 7, 9,32, 38]. Although this is not a paper on mesh generation,

Fig. 2 The Approximate Topological Matching Problem. Quads in(dark) red denote mismatched regions. In spite of there being majorpieces of the first mesh missing from the second, the parts of similarlyare still matched (the two right hands actually do not match topologi-cally, as the hand of the second model is attached differently)

we note that the mesh generation process often provides uswith properties we can exploit in our algorithms. For exam-ple, many mesh generation and remeshing algorithms createlarge patches of structured submeshes, each having degree 4(e.g., see [1, 14, 33, 35, 42]). Such submeshes are still rela-tively common, of course, even if not directly constructed,since, by an easy argument that follows directly from Euler’sformula, the vertices in any quad mesh of bounded genushave average degree equal to 4.

1.1.2 Mesh compression

One tool we use in our approximate topological matchingalgorithm is to compress the original quad mesh so as to re-duce the number of candidate starting points for our match-ing process. The problem of mesh compression has histori-cally been studied in the classic sense of data compression,where one wishes to produce a concise representation of amesh for the sake of reduced transmission and storage costs[10, 22, 24, 25, 41, 43]. Our reason for using mesh com-pression instead is based on the desire to speed up the com-putation time in an algorithm that operates on quad meshes.Thus, our approach actually fits the spirit of other algorithms(e.g., see [18, 19, 39, 45]) that perform data compression soas to improve algorithmic performance.

Page 13: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

Approximate topological matching of quad meshes 773

1.1.3 Graph isomorphism

In the classic graph isomorphism problem, we are given agraph G = (V ,E) and a graph H = (W,F ) with |V | = |W |and |E| = |F |, and we are asked if there is a mappingf : V −→ W such that edge e = (v,w) is an edge in E ifand only if (f (v), f (w)) is an edge in F . Applied to themesh matching problem, graph isomorphism correspondsto the problem of finding an exact topological match withno edges, vertices, or faces unmatched between the two in-put meshes. Much work has been done on the graph iso-morphism problem for general classes of graphs (e.g., see[11, 21, 28]), for which it is not known whether graph iso-morphism can be solved in polynomial time or if the graphisomorphism problem is NP-complete. For the special caseof planar graphs, or more generally for models of boundedgenus, isomorphism can be solved in linear time [23, 27],but these algorithms are fairly complex.

The problem of solving graph isomorphism for meshescan be solved in polynomial time, even for models of highgenus. The reason is that, in addition to their graph structure,meshes possess structure derived from the fact that they areembedded in manifold surfaces. In particular, such embed-dings impose a specific, given ordering on the edges aroundeach vertex, v, which corresponds to a clockwise or counter-clockwise listing of the edges incident to v. Thus, given amapping of an edge in G to an edge in H , it is a simple mat-ter to “grow out” the respective corresponding matching be-tween G and H so long as such matches are possible. Thatis, there is a simple O(m2) algorithm for finding an exacttopological match between two m-edge meshes (or deter-mining that no such matching exists)—attempt to grow outa possible match between G and H starting from each possi-ble matching of edges in G to a given edge e in H . In practi-cal applications, such algorithms are still too slow, however,and we address practical algorithms for the graph isomor-phism problem on quad meshes in a different paper [16].Our approach in this other paper is based on a techniquethat is inappropriate for solving the approximate topologicalmatching problem.

1.1.4 Graph edit distance

The approximate topological matching problem is related tothe problem of computing the edit distance between twographs [6, 8, 17, 31]. The concept of graph edit distancewas first introduced by Eshera and Fu [17]. It involves thecomputation of a measure of similarity between two graphsbased on the minimum number of edit operations, suchas edge insertions/deletions and vertex insertions/deletions,that would be needed to convert one graph into another,which is a problem shown to be NP-hard. Subsequent workhas focused on heuristic methods for computing graph edit

distance. For example, Berretti et al. [6] describe a distancemetric on graphs and apply it to content retrieval for colorimages, and Neuhaus and Bunke [31] use automatic learningmethods to compute the functions for graph edit distance.

The approximate topological matching is not the sameas graph edit distance, however. Graph edit distance is con-cerned with minimizing the number of edit operations toconvert one graph to another, whereas approximate topolog-ical matching is concerned with maximizing the amount ofcommon matching quads between two quad meshes, evenif there are large portions of one of the two meshes thatmight not match with any part of the other. Thus, the ap-proximate topological matching problem is an adaptationof the maximum common subgraph problem [26] to quadmeshes, where we wish to match oriented quad faces as wellas vertices and edges. The distinction between edit distanceand approximate topological matching is important in objectmodeling applications, for instance, where one mesh couldbe an early version of a model, such as a character’s face,before new facial features are added, such as eyebrows, eyelashes, and warts, and we want to match the earlier versionas best as possible against the current version. In such cases,it is better to ignore the mismatching parts rather than weighthem negatively in an edit distance value.

1.2 Our results

In this paper, we study the approximate topological match-ing problem for quadrilateral meshes. We show that thisproblem is NP-hard and that it has a decision version that isNP-complete. Together, these results imply that it is very un-likely that there is a polynomial-time algorithm for approxi-mate topological matching. Thus, we develop a heuristic al-gorithm for approximate topological mesh matching, basedon the use of a skeleton graph that is a well-defined, robustsubgraph of the mesh. This skeleton is then used to identifyanchors to begin a matching process similar to the way themedial axis is visualized for a polygon (e.g., see [12, 34]).If we imagine that the plane is made of a combustible ma-terial and we start a fire starting from each boundary edgeof the polygon, then the medial axis is defined by the placeswhere two waves of fire meet. In our case, we apply this ap-proach to quad meshes, viewing the quads as “combustiblematerial” and the anchors as the starting points for our fires.We grow regions in the two input meshes simultaneously,matching similar topological substructures as we go.

Such a fire-propagation approach to matching the two in-put meshes has an unfortunate complication, however. Inparticular, if we use the natural greedy approach to propa-gate matching portions of the wavefront, then this processcan lead to poor matches. Specifically, we show that even ifone small portion of one mesh is shrunk relative to a por-tion in the other, this greedy algorithm can produce globally

Page 14: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

774 D. Eppstein et al.

poor matches. Nevertheless, we show that our fire-growingapproach to approximate matching can be made to work ef-fectively even in these cases, by growing the wavefronts in a“lazy-greedy” fashion. In addition, we provide experimentalresults that show that the lazy-greedy algorithm can producegood matches quickly in practice.

2 Preliminaries

Before we discuss our results, let us give some preliminarydefinitions and observations about quadrilateral meshes.

2.1 The topology of quad meshes

Any graph drawn on the sphere S0 in three-dimensionalspace partitions the surface of S0 into cells such that eachis homeomorphic to a disk (we will always assume in thispaper that graphs are drawn without edge crossings). Eachsuch cell is called a face in the embedding. Adding g “han-dles” to S0 gives the surface Sg , which is said to havegenus g. For example, a traditional coffee cup is of genus 1.Likewise, the dog toy shown in Fig. 3 has genus 16.

A cellular embedding of a graph on Sg is a drawing thatpartitions Sg into cells such that each is homeomorphic to adisk. We define a quadrilateral mesh to be a cellular embed-ding of a graph G = (V ,E) onto a surface Sg such that eachface is a quadrilateral. We say that the genus of the meshis g in this case. We therefore view a quad mesh as a triple(V ,E,Q) where V is a set of vertices, E is a set of edges,and Q is a set of quadrilaterals. In addition, we assume thatquad meshes are represented with a data structure, like the“winged edge” structure [4], that supports the following op-erations:

– List the incident edges around a given vertex (in clock-wise or counter-clockwise order) in time proportional tothe degree of that vertex.

– List the bounding edges around a given face (in clock-wise or counter-clockwise order) in time proportional tothe size of that face.

– List the two vertices that are the endpoints of a given edgein constant time.

Fig. 3 A dog toy, which hasgenus 16

The simplest form of quad mesh is a structured mesh, whereevery vertex has degree four. The average degree of verticesin a bounded-genus quad mesh is 4, and it is common forthe majority of vertices in a quad mesh to have degree 4. Forthis reason, if a vertex in a quad mesh is an interior vertexwith degree different than 4, or an exterior (boundary) vertexwith degree different than 3, then we refer to that vertex asan extraordinary vertex.

2.2 The size of a quad mesh

Traditionally, an algorithm operating on a graph G is charac-terized in terms of n = |V |, the number of vertices of G, andm = |E|, the number of edges in G. We have these measuresin quad mesh algorithms as well, but we also have q = |Q|,the number of quads, so it is useful to relate these quantities.

Observation 2.1 In a quad mesh with m edges and q faces,2q ≤ m ≤ 4q .

Proof If we sum up the number of edges on every face, wewill count each edge at least once and at most twice. Sinceeach face is a quadrilateral, 4q ≤ 2m and m ≤ 4q . �

Observation 2.2 The number of edges and faces in a quadmesh can be arbitrarily larger than the number of vertices.

Proof We can place two vertices at opposite poles of asphere and add as many edges as we like joining them. Nowremove the sphere and enlarge each edge to be a thin tube.Next, take each original vertex and split into two points sep-arated by the width of a tube, with one on top and one on thebottom. This creates a shape similar to the dog toy shown inFig. 3. Now, for each tube, run an edge between the two topvertices, an edge between the two bottom vertices, and anedge joining top to bottom at each pole. This creates a quadmesh with four vertices and an arbitrary number of faces andedges. �

Although it is not uncommon in the solid modeling lit-erature to allow for such multiple edges and even self loopsin the graph defined by a quadrilateral mesh, we will restrictourselves in this paper to simple meshes, where we disallowmultiple edges (between the same pair of vertices) and selfloops. Likewise, we disallow multiple edges and self loopsin the dual graph, which is formed by placing a vertex ineach quad and joining two quads Q and R with an edge anytime Q and R have an edge of the mesh in common. Like-wise, we require that the mesh be well formed, meaning thatit satisfy the following:

1. For each vertex v, the set of quads containing v is con-nected in the dual graph.

Page 15: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

Approximate topological matching of quad meshes 775

2. The boundary of a quadrilateral mesh M consists of alledges of E that belong to exactly one quadrilateral in M

and all vertices incident to an edge of this type. For everycyclic portion C of the boundary of M on Sg (that is, a“hole” in the mesh), the interior of C is homeomorphicto a disk. That is, each hole in M is contractible.

3. Every edge in M is adjacent to at least one and at mosttwo quadrilateral faces of M .

4. Any two quadrilaterals in Q intersect in a single edge, asingle vertex, or the empty set.

Observation 2.3 In a simple, connected, well-formed quadri-lateral mesh M of genus g, with n vertices and m edges,

m ≤ 2n + 4g − 4.

Proof Since M is a simple, cellularly embedded graph inSg , the Euler characteristic implies that

n − m + q = 2 − 2g.

Specifically, the Euler characteristic (which is also knownas “Euler’s formula” or the “Euler–Poincaré characteristic”)states that, in such embeddings, the number of vertices mi-nus the number of edges plus the number of faces is equalto 2 − 2g. That is, in our case, m = n + q + 2g − 2. ByObservation 2.1, q ≤ m/2. Thus, m ≤ 2n + 4g − 4. �

In almost all practical applications of quadrilateral meshes,the genus g of a given mesh is bounded by constant and isalmost certainly O(n). Thus, the above lemma implies thatin almost every practical application using a mesh M withn vertices and m edges, m is O(n). Thus, for example, thetime complexity of the simple wave-growing exact graphisomorphism algorithm on such meshes is O(n2). We alsohave the following.

Lemma 2.1 In a simple, connected, well-formed quadrilat-eral mesh M of genus g, with n vertices and m edges,

m ≤(√

4

3g + 2

)n − 4.

Proof The proof follows that of a similar lemma of Woodand Telle [44] but is adapted to quad meshes. From Obser-vation 2.3 we know that

m ≤ 2n + 4g − 4.

So we need to show that 4g ≤ (

√43g)n. That is, we need to

show that g ≤ n2/12. This follows from the fact that M issimple and the complete graph on n vertices, Kn, has genusat most n2/12 (e.g., see [29]). �

3 On the difficulty of approximate topological matchingof quad meshes

As mentioned above, the problem of finding a best approx-imate topological match between two quad meshes has sev-eral uses in object representation and rendering applica-tions. Unfortunately, as we show in this section, the prob-lem of finding an optimal approximate topological match isNP-hard.

In order to be precise, let us formalize the approximatetopological matching problem for quad meshes. Supposethat we are given two quadrilateral meshes, M1 and M2.A matching submesh S1 of M1, with respect to M2, is a con-nected set of quads in M1 that is mapped one-to-one to aconnected set of quads in M2 by a function μ that mapsquads in S1 to quads in M2 such that q1 and q2 are adja-cent in S1 if and only if μ(q1) and μ(q2) are adjacent inM2 (using adjacency across edge boundaries). The approx-imate topological matching problem is to find a matchingsubmesh S1 of M1, with respect to M2, and the correspond-ing mapping function μ such that S1 has the largest numberof quads over all such submeshes. Unfortunately, we havethe following.

Theorem 3.1 The approximate topological matching prob-lem for quad meshes is NP-hard.

Proof We will give a reduction from the known NP-complete problem of determining if a given cubic planargraph is Hamiltonian [20]. Suppose then that we are givenan n-vertex cubic planar graph G as input, that is, a graphG that has degree 3 and which can be drawn in the planewithout crossings. Our proof is based on showing that wecan construct two meshes M1 and M2 in polynomial timesuch that all but n quads of M1 can be matched with part ofM2 if and only if G is Hamiltonian, that is, G contains as acycle that visits each vertex in G exactly once. We begin ourconstruction by using any existing polynomial-time method(e.g., see [3, 13, 36]) to produce an embedding of G in anO(n)×O(n) integer grid, where n is the number of verticesin G. This embedding allows us to associate integer coordi-nates in the plane to the vertices of G, from which we willbuild a quad mesh, M2. Before we perform this construc-tion, however, let us first build the mesh M1 that we want tomatch completely to M2.

In particular, let C be a simple cycle with n vertices, say,embedded at regular intervals around the boundary of a suf-ficiently large circle in the plane (separate from the grid G

is embedded in). We construct a mesh M1 from C by ex-panding each edge of C into a connected sequence of fourquads, linked in a “chain,” and expanding each vertex of C

according to the replacement submesh of four quads shownin Fig. 4a. That is, if we have an edge (u, v) in C connecting

Page 16: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

776 D. Eppstein et al.

Fig. 4 Gadgets used to prove that approximate topological matchingis NP-hard: (a) the vertex replacement submesh for C, (b) the vertexreplacement submesh for G

u to v that is followed by an edge (v,w), we replace (u, v)

by a chain of four quads that connect to v’s four quads asin the lower-right part of Fig. 4a, and we have the chain offour quads for (v,w) connected as in the upper-left part ofFig. 4a.

We convert G into a second quad mesh M2 by expandingeach edge into a chain of four quads, as in our construc-tion of M1, but we connect them to vertices in a differentway. Specifically, each vertex in G has degree 3, so we in-stead connect each edge chain of four quads according tothe replacement mesh shown in Fig. 4b. The dashed linesin the figure show all the possible ways that a maximumnumber of quads in a vertex submesh from M1 can matcha maximum number of quads in the vertex submesh in M2.Namely, a vertex submesh of four quads in M1 can match atmost three quads in a vertex submesh M2. That is, all but oneof the quads in a vertex submesh of M1 can match in a vertexsubmesh of M2. Also, note that the same cannot be said ofthe submeshes of M1 associated with edges of C. Namely,note that since each edge in C is expanded into a connectedchain of four quads, the quads in an edge submesh of M1

can match at most two quads in a vertex submesh of M2.In other words, to get the largest number of matching quads

between M1 and M2, we need to match vertex submeshes inM1 to vertex submeshes in M2.

So we have yet to show that G is Hamiltonian if and onlyif all but n of the quads in M1 can be matched with quadsin M2. Suppose that G is Hamiltonian. That is, C is a sub-graph of G; hence, we can match each vertex submesh ofM1 with a vertex submesh of M2, using the cycle C as aguide on how to similarly match each edge submesh of M1

with an edge submesh of M2, again, using the embedding ofC in G as a guide. Then there is a topological match of M1

in M2 that pairs up all but n quads from M1, i.e., the numberof matched quads between M1 and M2 is 7n.

Suppose, on the other hand, that there is a match of M1

and M2 that matches 7n quads, that is, all but n quadsfrom M1. As we have noted above, the only way this can oc-cur is if the edge submeshes of M1 match edge submeshesof M2 and three quads in each vertex submesh of M1 matchinside a vertex submesh of M2. Thus, C is a subgraph of G,that is, G is Hamiltonian. This completes the proof. �

In addition to the optimization problem of finding thebest approximate topological match between two quadrilat-eral meshes, we can create a decision version of the prob-lem:

Given two quad meshes, M1 and M2, and an integerparameter, K , is there a topological match of meshesfrom M1 to M2 such that the number of matched quadsis at least K?

This decision problem is also difficult.

Theorem 3.2 The decision version of the approximate topo-logical matching problem for quad meshes is NP-complete.

Proof To show that this decision version is NP-compete, weneed to show it is in NP and that it is NP-hard. First, to seethat it is in NP, note that if we nondeterministically guessan assignment of quads in M1 to M2, we can verify in poly-nomial time that this assignment satisfies the connectivityrequirements to be a topological match and that the numberof matching quads is at least K . Thus, this decision versionof approximate topological matching is in NP. To show thatit is NP-hard, all we need to do is repeat the proof of Theo-rem 3.1 using K = 7n. �

4 A heuristic algorithm for approximate topologicalmatching

Given that the approximate topological matching problemis NP-hard and that it has a decision version that is NP-complete, it is very unlikely that there is an efficient algo-rithm for solving it exactly. Thus, let us discuss heuristicapproaches.

Page 17: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

Approximate topological matching of quad meshes 777

4.1 Identifying anchors via color assignment

Let us begin with the starting point for our heuristic algo-rithm, the identification of good anchors that can seed theprocess of matching pairs of quads in the input meshes M1

and M2, that is, extraordinary vertices in M1 and M2 thathave relatively distinctive neighborhoods. Note: if there areno extraordinary vertices at all (e.g., if M1 and M2 are tori),then we pick an arbitrary pair of vertices in M1 and M2 asanchors.

In order to find a good set of anchors in the general case,we apply a few iterations of the Weisfeiler and Leman (WL)algorithm for exact graph isomorphism (e.g., see [21]). Re-call that in the WL algorithm, we initially label each vertexwith a label associated with its degree.1 Then, each vertex islabeled by a string of its neighbors’ labels in an order thatappears in the topological embedding. In turning the cyclicordering into a linear ordering, we pick the one that is lex-icographically minimum. Then we let these strings be thenew labels of the vertices (which we can renormalize to bethe integers from 1 to n with a simple radix sort). Algo-rithm 1 gives a pseudocode for this procedure, which viewsthe vertex labels as “colors.”

Observe that the second loop in Algorithm 1 can be re-peated to refine the color labels of vertices. This repetitionshould be done until we reach a reasonable stopping condi-tion. For example, we used the stopping condition of repeat-ing until we reach a set upper bound, k, on the number ofiterations or until at least one pair of uniquely labeled ver-tices are found, one from each mesh. If we repeat this loopi times, the label of each vertex u will contain informationabout the vertices that are within distance i from u. The run-ning time of this second loop is 2m = O(m), which is O(n)

in the case of planar meshes or meshes of at most lineargenus, by Observation 2.3.

Algorithm 1 Algorithm for ColorGraph

1Not only the degree of each vertex can serve as the seed for labels; wemay also choose to use the edge weights in the compressed meshes. Inorder to do so, we can label each edge by number of edges contractedwhile compressing the meshes.

The final step of the algorithm for identifying seeds toinitiate mesh-matching growth from is that of finding cor-responding anchors from the labeled compressed meshes.In order to find such seeds, we first match the rarest (hope-fully unique) labeled vertices returned from the two com-pressed meshes and then look for matching neighbors of thetwo matched vertices. Again, for most meshes, this processtakes O(n) time in the worst case, by Observation 2.3 orLemma 2.1.

4.2 Skeleton graphs: compressing meshes for improvedanchor finding

As noted above, we are interested in finding rare or evenuniquely labeled anchors, so as to limit the number of pos-sible candidate starting points for growing matching sets ofquads between the two input meshes. Thus, it makes intu-itive sense that we should concentrate on extraordinary ver-tices. In order to focus on the adjacencies between these ver-tices, we apply a compression scheme that focuses on extra-ordinary vertices and in most cases reduces the size of thegraph we must deal with.

4.3 Particle shooting

The idea for constructing this compressed skeleton graphinside each mesh is quite simple: we imagine that we shoota particle out along every possible edge going out of eachextraordinary vertex. These particles travel separately alongthe edges going out from extraordinary vertices. When a par-ticle enters a normal vertex, it continues through that vertexand leaves out the opposite side (unless this is a boundaryvertex and there is no edge on the other side). In propagat-ing these fictitious particles in this way we trace out a sub-graph in each input mesh, M1 and M2. We let the particlescontinue to move, tracing out the compressed graph we aregoing to use for color label assignment, until each such par-ticle reaches another extraordinary vertex (which is a verycommon occurrence given the way that people build quadmeshes in practice) or the particle reaches a boundary edge.We then perform our anchor-finding procedure on this skele-ton graph. (See Fig. 5.)

4.4 A false start: the greedy algorithm

Given a set of anchors to begin our matching process, per-haps the most natural heuristic algorithm for solving theapproximate topological matching problem is to start witha seed pair of matching quads, starting at some candidateanchors, and grow out matching meshes from this startingpoint.

The natural greedy algorithm that is based on this ap-proach would be to grow out the matching set of quads in

Page 18: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

778 D. Eppstein et al.

Fig. 5 Anchor finding in a simple quad mesh, M1. This mesh hasfive extraordinary vertices consisting of the four corners and the vertexmarked “start.” The vertex marked “start” is the best candidate for ananchor in this mesh, since the neighborhood structure of the other fourextraordinary vertices are similar to each another. The edges traversedin the “particle-shooting” process are shown bold

waves, adding as many quads as possible so as to satisfy theadjacency constraint for quads (e.g., by restricting our at-tention to quads that are adjacent across an edge or vertex).Unfortunately, this greedy approach suffers from a seriousdrawback, which is highlighted by a simple example.

Suppose that we are given two similar meshes, M1 andM2, as, for example, shown in Figs. 5 and 6, such that M2

is an exact match for M1 except that some small group ofquads in M2 is compressed into a set of edges.

Suppose further that we grow out sets of matching quadsin M1 and M2 starting from some anchor point, using thegreedy approach of matching as many quads as possiblewith each wavefront propagation. When this propagatingwavefront reaches the set of compressed quads, it will cor-rectly match long sets of quads on each side of the mis-matching portion. But it will also incorrectly match as manyquads as possible across the compressed edges as well. Un-fortunately, this sets off a cascading failure, as the wave-front that propagated across the compressed quads will beout of phase with the (correct) sets of quads that are beingmatched as they go around the compressed region. The cas-cade continues because the incorrectly matched quads arebeing “grown” ahead of the correctly matching quads. Thus,the correctly matching quads never have a chance to “catchup” to this wave, and this bad behavior can continue cascad-ing across the entire mesh. This unfortunate growth pattern

Fig. 6 A candidate quad mesh, M2. Note that M2 is an exact matchfor the quad mesh M1 from 5 except that three quads in the middle arecompressed into individual edges in M2

Fig. 7 An unfortunate cascading failure in M2 caused by the greedymesh growing algorithm applied to the meshes of Figs. 5 and 6

is illustrated for the meshes M1 and M2 of Figs. 5 and 6 inFig. 7.

Thus, we do not recommend that the greedy algorithm beused as a heuristic for solving the approximate topological

Page 19: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

Approximate topological matching of quad meshes 779

matching problem. Instead, we advocate the use of a lazy-greedy approach.

4.5 The lazy-greedy algorithm

In this section, we discuss our lazy-greedy approach tosolving the approximate topological matching problem fortwo quad meshes by using a wavefront “fire-propagation”method.

4.5.1 The main idea behind our matching algorithm

The main idea behind this oxymoronic algorithm is to growout waves of matching quads, as in the greedy algorithmgiven above as a false start, but to do so in a more relaxedway that helps to avoid the cascading failures that can arisefrom the straightforward greedy algorithm.

Let us assume that we have done an initial color label-ing and have found a set of anchors to begin the matchingprocess from in M1 and M2. The goal of the lazy-greedyalgorithm is to incrementally build a mapping function, μ,that matches quads in M1 to quads in M2. Initially, μ mapsthe two anchor quads in M1 and M2 to each other (definingan edge in the dual graph). As we proceed, we track of theset of quads where we can expand the matching function μ

to more quads. Let S be the set of currently matched quads,that is, all quads q in M1 for which we have determined amatching quad, μ(q). Since we start matching from a seed,at each iteration, S forms a contiguous block of quads in M1

with a corresponding set of matching quads, μ(S) in M2.Now, let S′ be a subset of quads in S on the boundary ofthe contiguous submesh S, that is, quads that have adjacentunmatched neighbors. When growing the match at each it-eration, note that we only need to consider quads that areeither vertex or edge adjacent to quads in S′ or μ(S′), sincethe quads that are interior to the contiguous block have noadjacent unmatched quads.

4.5.2 Using a compatibility graph for growing matchingsubmeshes

Let A be the set of unmatched quads in M1 that are ver-tex or edge adjacent to quads in S′, and let B be the setof unmatched quads in M2 that are vertex or edge adjacentto quads in μ(S′). For each quad q in A, let M(q) be theset of quads in B that could match with q , that is, we in-clude in M(q) each quad r in B such that r is adjacent toa quad μ(t) with q being adjacent to t in the same way asr and μ(t) (i.e., across a corresponding vertex or edge adja-cency).

Let us create a compatibility graph L by defining, foreach M(q), a vertex vi,q for each quad in M(q). Note thatsame quad in B might be listed in different M(q) sets, in

which case we create a different vertex in L for each copyof that quad in the different M(q) sets. We say that a vertexvi,q is adjacent to vertex vi,s in L if

– q and s are adjacent across an edge in M1.– The quads, r and t in M2, corresponding respectively to

vi,q and vi,s are compatible in M2, meaning that if wewere to extend μ by mapping q to r and s to t , then thesubmesh in M1 consisting of q and s and all their adjacentquads in S′ would be consistent (in the topological sense)with the submesh in M2 consisting of r and t and all theiradjacent quads in μ(S′).

Note that the graph L consists of paths, isolated vertices, ora cycle, i.e., vertices in L have degree at most 2.

4.5.3 The lazy-greedy heuristic

The lazy-greedy heuristic is to extend μ in each iteration byadding the matches defined by a largest connected compo-nent (i.e., path or cycle) in L. Note that this is a greedy algo-rithm in the sense that it is augmenting our match using anoptimization criterion that maximizes an objective function.But it is also a lazy algorithm in that it postpones perform-ing a lot of potentially valid matches between quads in M1

and M2 just because they did not belong to the largest con-nected component in the compatibility graph L. We repeatthis lazy-greedy heuristic process until the current versionof L contains no vertices. (See Fig. 8.)

The benefit of the lazy-greedy approach is that it allowsour matching process to match the quads around a smallmismatching region even when the mismatch is caused bya compression of quads into individual edges. Such a com-pression causes the greedy algorithm to immediately marchthrough these bad regions, whereas the lazy-greedy algo-rithm will only venture into such regions as a last resort. We

Fig. 8 The lazy-greedy algorithm. The shaded (blue) regions collec-tively denote S′, the currently matched quads. The labeled quads inboth meshes correspond to the pairs of quads that share the same ad-jacent quads in S′. Finally, we show the compatibility graph L con-structed from the quads adjacent to S′. Since quads 4, 5, and 6 formthe largest connected component in L, we match these quads at thisiteration

Page 20: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

780 D. Eppstein et al.

illustrate the difference this approach makes for the meshesM1 and M2 of Figs. 5 and 6 in Fig. 9.

5 Experimental results

We have empirically tested the two main claims of our ap-proach on real-world meshes from the character databaseat Walt Disney Animation Studios. The first claim that wetested is the following:

– The skeleton graph constructed by our algorithm signif-icantly compresses quad meshes in a way that preservesessential features.

Fig. 9 An isolation of a small mismatching region in M2, showinghow the lazy-greedy algorithm avoids the unfortunate cascading failurecaused by the greedy mesh growing algorithm applied to the meshes ofFigs. 5 and 6

Table 1 gives an overview of the size of skeleton graphsfor a number of the models in the Disney character database.

Note that the reduction percentages average around 75%,and that they range from a low of 66% for the girl of Fig. 12and a high of 97% for the chick of Fig. 10. The main pointof this compression is not for storage savings, however, al-though it could be used for this purpose, since the regionsbounded by edges of the skeleton graph are all structuredmeshes. Instead, we use the skeleton graph to drive our ap-proximate matching process.

Another claim of our method is the following:

– The lazy-greedy algorithm runs fast enough for interac-tive modeling purposes.

The running times for our matching process, applied to thesame characters as used for skeleton graph computations areshown in Table 2. Note that the average running time forthis set of models is less than half a second and that it corre-sponds proportionally to the mesh sizes. The second meshesin these cases correspond to similar models (e.g., two bears),alternate poses, and across symmetries (e.g., in a shirt).

Note that all the running times for approximate matchingare at a second or less. This is certainly sufficient for inter-active modeling purposes. Moreover, it significantly speeds

Fig. 10 A compressed mesh; edges in red denote the compressedmesh

Table 1 Sizes of skeleton graphs for various quad mesh models

Model Original mesh Skeleton graph Reduction

Vertices Edges Vertices Edges (%)

bear 1070 2110 202 393 81%

chick 932 1827 32 56 97%

shirt 3099 6134 518 1015 83%

director 9958 19889 2510 5001 75%

tommy 10281 20530 2496 4973 76%

body 13238 26457 3176 6339 76%

girl 6976 13903 2340 4647 66%

Page 21: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

Approximate topological matching of quad meshes 781

Table 2 Running times for approximate topological matching of var-ious quad mesh models

Model Mesh size Time

Vertices Edges (seconds)

bear 1070 2110 0.04

chick 932 1827 0.02

shirt 3099 6134 0.12

director 9958 19889 0.72

tommy 10281 20530 0.76

body 13238 26457 1.08

girl 6976 13903 0.65

Fig. 11 Approximate matching; quads in (dark) red denote mis-matched regions. Only the ears, which are indeed topologically dif-ferent, were not matched

up what used to be a semi-automated process that involvedhuman input of a pair of edges to use as anchors.

Finally, we also make the following claim for our algo-rithm:

– The lazy-greedy algorithm finds good approximatematches.

Naturally, since we are not aware of any other approximatetopological matching algorithms, testing this claim againstother algorithms is not possible. Nevertheless, we can provethat our algorithm is successful in many cases. Suppose,for example, that there is a mapping between two simple,connected, well-formed quad meshes M1 and M2 such thateach connected mismatched region has boundary complex-ity of at most δ. Suppose further that the medial axis of thematched region for M1 and M2 is connected and has a span-ning tree T such that each edge of T has a cross-sectionalwidth of at least ε > 2δ. Then our algorithm will succeed infinding a match at least as good as this match.

Fig. 12 An approximate matching result; quads in (dark) red denotemismatched regions. This example shows how the lazy-greedy algo-rithm tolerates both modest mismatches and massive mismatches, asin Fig. 2, unlike approaches based on minimizing edit distance. (Thetwo right hands actually do not match topologically, as the hand of thesecond model is attached differently)

In addition, a subjective evaluation of the matches our al-gorithm produced on the Disney character database demon-strated that our algorithm empirically found good matches.For example, we show the quality of the matches producedby our algorithm on the bears and girl models in Figs. 11and 12. In addition, an animation of our algorithm is avail-able for download at the following location:

www.ics.uci.edu/~eppstein/projects/firefront.mov

6 Conclusion and future directions

In this paper, we study the approximate topological match-ing problem for quad meshes, showing that this problem isNP-hard in general. Nevertheless, we provide an efficientheuristic algorithm that works well in practice and provablywell for a large class of models that is common in practice.

Directions for future work include the following:

– Our methods are directed at connected models. How hardis it to extend the lazy-greedy algorithm to handle discon-nected models?

Page 22: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

782 D. Eppstein et al.

– Our methods find a single connected region of matchingquads. Is there a way to generalize the lazy-greedy ap-proach to handle disconnected matching regions in a waythat maintains distance and intuitive correspondence asmuch as possible?

Acknowledgements This research was done while the first two au-thors were consultants for Walt Disney Animation Studios. Likewise,this research was done while the third author was a summer intern forWalt Disney Animation Studios. This paper appeared in preliminaryform as [15] in IEEE Int. Conf. on Shape Modeling and Applications(SMI) 2008.

References

1. Alliez, P., Cohen-Steiner, D., Devillers, O., Lévy, B., Desbrun, M.:Anisotropic polygonal remeshing. In: SIGGRAPH’03: ACM SIG-GRAPH 2003 Papers, New York, NY, USA, pp. 485–493. ACM,New York (2003)

2. Armstrong, C.G., Robinson, D.J., McKeag, R.M., Li, T.S., Brid-gett, S.J., Donaghy, R.J.: Applications of the medial axis transformin analysis modelling. In: NAFEMS, Proc. 5th Int. Conf. Reliabil-ity of FEM for Engineering Applications, pp. 415–426 (1995)

3. Battista, G.D., Eades, P., Tamassia, R., Tollis, I.G.: Graph Draw-ing: Algorithms for the Visualization of Graphs. Prentice-HallPTR, Upper Saddle River (1998)

4. Baumgart, B.G.: Winged edge polyhedron representation. Techni-cal Report CS-TR-72-320, Stanford University (1972)

5. Bern, M.W., Eppstein, D.: Quadrilateral meshing by circle pack-ing. Int. J. Comput. Geom. Appl. 10(4), 347–360 (2000)

6. Berretti, S., Bimbo, A.D., Pala, P.: A graph edit distance based onnode merging. In: Image and Video Retrieval. Lecture Notes inComputer Science, vol. 3115, pp. 464–472 (2004)

7. Blacker, T.D., Stephenson, M.B.: Paving: a new approach to auto-mated quadrilateral mesh generation. Int. J. Numer. Methods Eng.32, 811–847 (1991)

8. Bunke, H.: On a relation between graph edit distance and maxi-mum common subgraph. Pattern Recognit. Lett. 18(8), 689–694(1997)

9. Chae, S.-W., Jeong, J.-H.: Unstructured surface meshing usingoperators. In: Proc. 6th Int. Meshing Roundtable, pp. 281–291(1997)

10. Cohen-Or, D., Levin, D., Remez, O.: Progressive compressionof arbitrary triangular meshes. In: Proc. 10th IEEE Visualization(VIS’99), p. 11 (1999)

11. Corneil, D.G., Gotlieb, C.C.: An efficient algorithm for graph iso-morphism. J. ACM 17(1), 51–64 (1970)

12. de Berg, M., van Kreveld, M., Overmars, M., Schwarzkopf, O.:Computational Geometry: Algorithms and Applications, 2nd edn.Springer, Berlin (2000)

13. de Fraysseix, H., Pach, J., Pollack, R.: Small sets supporting Fáryembeddings of planar graphs. In: STOC’88: Proceedings of theTwentieth Annual ACM Symposium on Theory of Computing,New York, NY, USA, pp. 426–433. ACM Press, New York (1988)

14. Dong, S., Bremer, P.-T., Garland, M., Pascucci, V., Hart, J.C.:Spectral surface quadrangulation. In: SIGGRAPH ’06: ACM SIG-GRAPH 2006 Papers, New York, NY, USA, pp. 1057–1066.ACM, New York (2006)

15. Eppstein, D., Goodrich, M.T., Kim, E., Tamstorf, R.: Approximatetopological matching of quadrilateral meshes. In: IEEE Int. Conf.on Shape Modeling and Applications (SMI), pp. 83–92 (2008)

16. Eppstein, D., Goodrich, M.T., Kim, E., Tamstorf, R.: Motorcyclegraphs: canonical quad mesh partitioning. Comput. Graph. Forum27(5), 1477–1486 (2008)

17. Eshera, M.A., Fu, K.S.: An image understanding system usingattributed symbolic representation and inexact graph-matching.IEEE Trans. Pattern Anal. Mach. Intell. 8(5), 604–618 (1986)

18. Feder, T., Motwani, R.: Clique partitions, graph compression andspeeding-up algorithms. In: Proc. 23rd ACM Symp. Theory ofComputing, pp. 123–133 (1991)

19. Ferragina, P., Manzini, G.: Opportunistic data structures with ap-plications. In: Proc. 41st Symp. Foundations of Computer Science,pp. 390–398 (2000)

20. Garey, M.R., Johnson, D.S.: Computers and Intractability:A Guide to the Theory of NP-Completeness. W.H. Freeman, NewYork (1979)

21. Grohe, M.: Isomorphism testing for embeddable graphs throughdefinability. In: STOC’00: Proceedings of the Thirty-Second An-nual ACM Symposium on Theory of Computing, New York, NY,USA, pp. 63–72. ACM Press, New York (2000)

22. Gurnhold, S., Strasser, W.: Real time compression of trianglemesh connectivity. In: Proc. 25th Conf. Computer Graphics andInteractive Technology, pp. 133–140 (1998)

23. Hopcroft, J.E., Wong, J.K.: Linear time algorithm for isomor-phism of planar graphs. In: Proc. 6th ACM Symp. Theory of Com-puting, pp. 172–184 (1974)

24. Khodakovsky, A., Alliez, P., Desbrun, M., Schröder, P.: Near-optimal connectivity encoding of 2-manifold polygon meshes.Graph. Models 64(3/4), 147–168 (2002)

25. King, D., Rossignac, J., Szymczak, A.: Connectivity compressionfor irregular quadrilateral meshes. Technical Report GIT-GVU-99-36, Georgia Institute of Technology (1999)

26. Marini, S., Spagnuolo, M., Falcidieno, B.: From exact to approxi-mate maximum common subgraph. In: Graph-Based Representa-tions in Pattern Recognition. Lecture Notes in Computer Science,vol. 3434, pp. 263–272. Springer, Berlin (2005)

27. Miller, G.: Isomorphism testing for graphs of bounded genus.In: Proc. 12th ACM Symp. Theory of Computing, pp. 225–235(1980)

28. Miller, G.L.: Graph isomorphism, general remarks. In: STOC’77:Proceedings of the Ninth Annual ACM Symposium on Theory ofComputing, New York, NY, USA, pp. 143–150. ACM Press, NewYork (1977)

29. Mohar, B., Thomassen, C.: Graphs on Surfaces. Johns HopkinsUniversity Press, Baltimore (2001)

30. Müller-Hannemann, M.: High quality quadrilateral surface mesh-ing without template restrictions: a new approach based on net-work flow techniques. In: Proc. 6th Int. Meshing Roundtable, pp.293–307 (1997)

31. Neuhaus, N., Bunke, H.: Automatic learning of cost functions forgraph edit distance. Inf. Sci. 177(1), 239–247 (2007)

32. Nowottny, D.: Quadrilateral mesh generation via geometricallyoptimized domain decomposition. In: Proc. 6th Int. MeshingRoundtable, pp. 309–320 (1997)

33. Palacios, J., Zhang, E.: Rotational symmetry field design on sur-faces. ACM Trans. Graph. 26(3), 55 (2007)

34. Preparata, F.P., Shamos, M.I.: Computational Geometry: An Intro-duction. Springer, New York (1985)

35. Ray, N., Li, W.C., Lévy, B., Sheffer, A., Alliez, P.: Periodic globalparameterization. ACM Trans. Graph. 25(4), 1460–1485 (2006)

36. Schnyder, W.: Embedding planar graphs on the grid. In: SODA’90:Proceedings of the First Annual ACM–SIAM Symposium on Dis-crete Algorithms, Philadelphia, PA, USA, pp. 138–148. Societyfor Industrial and Applied Mathematics, Philadelphia (1990)

37. Schonfeld, T., Weinerfelt, P.E.R.: The automatic generation ofquadrilateral multi-block grids by the advancing front technique.In: Numerical Grid Generation in Computational Fluid Dynamicsand Related Fields; Proceedings of the 3rd International Confer-ence, Barcelona, Spain, pp. 743–754 (1991)

Page 23: Approximate Topological Matching of Quadrilateral Meshes · 2013-06-20 · a maximum approximate topological match of two quad meshes in NP-hard. Given this result, which makes an

Approximate topological matching of quad meshes 783

38. Shimada, K., Liao, J.-H., Itoh, T.: Quadrilateral meshing with di-rectionality control through the packing of square cells. In: Proc.7th Int. Meshing Roundtable, pp. 61–75 (1998)

39. Smith, B.C., Rowe, L.A.: Algorithms for manipulating com-pressed images. Comput. Graph. Appl. 13(5), 34–42 (1993)

40. Talbert, J.A., Parkinson, A.R.: Development of an automatic two-dimensional finite element mesh generator using quadrilateral ele-ments and Bezier curve boundary definition. Int. J. Numer. Meth-ods Eng. 29, 1551–1567 (1991)

41. Taubin, G., Rossignac, J.: Geometric compression through topo-logical surgery. ACM Trans. Graph. 17(2), 84–115 (1998)

42. Tong, Y., Alliez, P., Cohen-Steiner, D., Desbrun, M.: Designingquadrangulations with discrete harmonic forms. In: SGP’06: Pro-ceedings of the Fourth Eurographics Symposium on GeometryProcessing, Aire-la-Ville, Switzerland, pp. 201–210. SwitzerlandEurographics Association (2006)

43. Touma, C., G.C.: Triangle mesh compression. In: Proc. GraphicsInterface, pp. 26–34 (1998)

44. Wood, D.R., Telle, J.A.: Planar decompositions and the crossingnumber of graphs with an excluded minor. N. Y. J. Math. 13, 117–146 (2007)

45. Yeo, B.-L., Liu, B.: Rapid scene analysis on compressed video.IEEE Trans. Circuits Syst. Video Technol. 5(6), 533–544 (1995)

David Eppstein is a professor andco-chair of the Computer ScienceDepartment at the University ofCalifornia, Irvine. He received hisPh.D. in Computer Science fromColumbia University in 1989, aftermajoring in Mathematics at Stan-ford University, and worked as apostdoctoral researcher at the Xe-rox Palo Alto Research Center from1989 to 1990 before joining theUCI faculty. His research special-ties include computational geom-etry, graph algorithms, and graphdrawing.

Michael T. Goodrich is a Chan-cellor’s Professor at the Univer-sity of California, Irvine, where hehas been a faculty member in theDepartment of Computer Sciencesince 2001. He received his B.A.in Mathematics and Computer Sci-ence from Calvin College in 1983and his Ph.D. in Computer Sciencesfrom Purdue University in 1987,and he worked as a professor in theDepartment of Computer Scienceat Johns Hopkins University from1987–2001. His research is directed

at algorithms for solving large-scale problems motivated from infor-mation assurance and security, the Internet, information visualization,and geometric computing.

Ethan Kim is a Ph.D. student atSchool of Computer Science, McGillUniversity. His research interestslie in discrete mathematics and ap-proximation algorithms, particularlywith geometric graphs, and is nowworking on graph-theoretic prob-lems from computational biology.He is a recipient of NSERC CanadaGraduate Award (2006) and Post-graduate Award (2007). His work onthis paper was done while he wasvisiting Walt Disney Feature Ani-mation as a graduate research asso-ciate.

Rasmus Tamstorf is a research sci-entist at Walt Disney AnimationStudios. Over the past 10 years atDisney he has worked on a vari-ety of projects including geometri-cal problems in rendering, a pro-duction pipeline based on subdivi-sion surfaces, and deformation algo-rithms for character animation. Heis currently working on various as-pects of cloth simulation and what-ever it takes to create the Disneymagic. Rasmus has a MS EE de-gree from the Technical University

of Denmark and film credits on Tarzan, Dinosaurs, Lilo & Stitch, andChicken Little, among others.