triangle mesh processing

67
Triangle mesh processing Slides by Marc van Kreveld for DDM 1

Upload: thelma

Post on 24-Feb-2016

32 views

Category:

Documents


0 download

DESCRIPTION

Triangle mesh processing. Slides by Marc van Kreveld for DDM. Triangle mesh processing. Changing the locations of vertices (improvement) Reducing the number of vertices (downsampling, simplification) Increasing the number of vertices (upsampling) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Triangle mesh processing

Triangle mesh processing

Slides by Marc van Kreveldfor DDM

1

Page 2: Triangle mesh processing

Triangle mesh processing

• Changing the locations of vertices (improvement)• Reducing the number of vertices (downsampling,

simplification)• Increasing the number of vertices (upsampling)• Fixing up holes and

other problems (repair) • Making levels

of detail

2

Page 3: Triangle mesh processing

Triangle mesh processing

• Downsampling for efficient storage, rendering and transmission– try to preserve quality

• Upsampling to ensure sufficiently small triangles when deformations are applied– try to improve quality

3

Page 4: Triangle mesh processing

Euler operators

vertex removal

vertex insertion

edge collapse

vertex split

halfedge collapse

restricted vertex split

4

Page 5: Triangle mesh processing

More operators

edge split

edge flip

edge flip

vertex relocate

vertex relocate

5

Page 6: Triangle mesh processing

Quality measures

• What can we all measure to “represent” quality of an operator, or difference between two meshes?– Hausdorff distance between a mesh and a changed version:

max distance over all points on one surface (mesh) to the nearest point on the other

6

Page 7: Triangle mesh processing

Quality measures

• What can we all measure to “represent” quality of an operator, or difference between two meshes?– change in volume between the two meshes– change of normals between the two meshes– shape/size of the triangles of the two meshes– lengths of the edges of the two meshes– difference in convexity/concavity at the edges– angular deficit at the vertices: 2 – the sum of the angles

of all triangles incident to a vertex (one angle per triangle)

7

Page 8: Triangle mesh processing

Quality measures

• Angular deficit: 2 – the sum of the angles of all triangles (facets) incident to a vertex (one angle per triangle/facet)

8

/2 2/3 – /3 (and /2)

Page 9: Triangle mesh processing

Quality measures for vertices

• Suppose we remove a vertex v of a mesh, consider the mesh before removal to be correct, then the mesh after removal has some error

• Then we can try to remove the vertex that induces the smallest error– in distance– in volume– in normals

• We need to retriangulate the gap, also while minimizing error

vertex removal

9

(3D)

Page 10: Triangle mesh processing

Quality measures for vertices

• The number of triangulations of a convex polygon with k vertices is k (k+1) (k+2) … (2k–4) / (k–2)!

value k 3 4 5 6 7# ways 1 2 5 14 42

• The number of triangulations of other polygons (gaps after removing a vertex from a polyhedron)is at most this large

vertex removal

10

?

Page 11: Triangle mesh processing

Approach for mesh simplification

• Choose a relevant error measure• Choose operators to be tried• Choose a target mesh size or max allowed error• While target not reached:– For all operators and all places to apply it:

• Compute (local) error measure before and after the operator• Keep the one with smallest loss

– Apply the operator that induces the smallest error according to the chosen measure

11

Page 12: Triangle mesh processing

Example: terrain simplification

• Assume a planar triangulation is given where every vertex also has a height (z-coordinate)

• Use vertical error as the measure• Use vertex removal as the operator, and always use

the (planar) Delaunay triangulation to fill the gap

12

Page 13: Triangle mesh processing

Terrain simplification

13

top view

Page 14: Triangle mesh processing

Terrain simplification

14

top view

Page 15: Triangle mesh processing

Terrain simplification

15

top view

Page 16: Triangle mesh processing

Terrain simplification

16

top view

Page 17: Triangle mesh processing

Terrain simplification

17

top view

Page 18: Triangle mesh processing

Terrain simplification

18

top view

Page 19: Triangle mesh processing

Terrain simplification

• The vertical error is only caused in each shaded region• We need to compute the maximum vertical distance

between two sets of triangles covering the same region– It occurs at the removed vertex or

at an edge-edge intersection– If a vertex has constant degree,

then this takes O(1) time• If all vertices have constant degree, then it takes O(n)

time overall to find the vertex whose removal causes the smallest error (mesh with n vertices)

19

Page 20: Triangle mesh processing

Terrain simplification

• Suppose we measure error only at the vertex?

20

perspective view

Page 21: Triangle mesh processing

Terrain simplification

• One iteration (vertex removal) takes O(n) time• E.g. halving the number of vertices takes O(n2) time• Efficiency improvement: note that in a next iteration,

nearly all vertices will compute the same error; only vertices adjacent to the vertex just removed have a different error

21

Page 22: Triangle mesh processing

Terrain simplification

• We can keep all these potential errors (resulting error if the vertex is removed) in a priority queue

• One iteration is then:– Remove the lowest error removal from the priority queue– Delete it from the mesh and restore it to be Delaunay– For the neighbors of the removed vertex:

• Remove them from the priority queue• Recompute the induced error• Insert in the priority queue

• One iteration typically takes O(log n) time now, instead of O(n)

22

Page 23: Triangle mesh processing

3D mesh simplification

• For vertex removal and other operators on 3D meshes we must make sure that the operator does not cause self-intersections (this cannot happen on terrains)

23

suppose we remove vertices on the backside of a boundary model of this spoon

Page 24: Triangle mesh processing

3D mesh simplification

• Some operators can be illegal because the resulting mesh would not be a 2-manifold (with or without boundary) anymore

24

edge collapse not allowed

Page 25: Triangle mesh processing

Making a mesh more uniform

• A simple method to spread points evenly in a space: move every point to the center of its Voronoi cell, and iterate this a few times (recompute the Voronoi diagram after moving all points, and move again)

25

Page 26: Triangle mesh processing

Making a mesh more uniform

Page 27: Triangle mesh processing

Making a mesh more uniform

Page 28: Triangle mesh processing

Making a mesh more uniform

Page 29: Triangle mesh processing

Making a mesh more uniform

Page 30: Triangle mesh processing

Making a mesh more uniform

Page 31: Triangle mesh processing

Making a mesh more uniform

Page 32: Triangle mesh processing

Making a mesh more uniform

Page 33: Triangle mesh processing

Making a mesh more uniform

Page 34: Triangle mesh processing

Making a mesh more uniform

• This can be done on a triangle mesh in 3D too, but one should use the Voronoi diagram on the surface and not the 3D Voronoi diagram

34

Page 35: Triangle mesh processing

Progressive meshes

• Multi-scale representation by Hoppe (1996)• Designed to address:– mesh simplification (reduce number of vertices)– level-of-detail approximation (allow various resolutions)– progressive transmission (successively refine a coarse

model when transmitting)– mesh compression (reduce storage)– selective refinement (allow different levels-of-detail in a

single mesh, e.g. for view dependency)

35

Page 36: Triangle mesh processing

Progressive meshes

• Main idea of the progressive mesh (PM): store a coarse mesh plus the sequence of operations to get to the most accurate/detailed mesh

36

M0 M1 Mn

most coarse mesh

mesh with one vertex more

mesh with n vertices more (most accurate)

Page 37: Triangle mesh processing

Progressive meshes

• Meshes for computer graphics: typically, much more than just geometry is stored– discrete attributes (material, …)– numerical attributes (color, normal, coordinates for a

texture, …)• Discrete attributes are stored with the triangles• Numerical attributes are stored with the corners of a

mesh (corner: a vertex-triangle pair; each triangle has three corners)

37

corner

Page 38: Triangle mesh processing

Progressive meshes

• A mesh M = (K, V, D, S) where– K is the connectivity information stored– V is the geometry (coordinates) stored– D is the set of discrete attributes stored with triangles– S is the set of numerical attributes stored with corners

(Hoppe calls it scalar attributes rather than numerical, and sees color and normal each as three separate values)

38

Page 39: Triangle mesh processing

Progressive meshes

• To build a PM, start with the most detailed version and then incrementally apply edge collapse operations to get from Mn to M0

• To get a good quality PM, a good scheme for choosing the next edge collapse must be found

39

edge collapse

vertex split

Page 40: Triangle mesh processing

Progressive meshes

• In the edge collapse of {vs,vt}, the vertex vt disappears and so do the triangles {vs,vt, vl} and {vs,vt, vr}

40

vl

vr

vs

vt

vl

vr

vs

Page 41: Triangle mesh processing

Progressive meshes

• The inverse vertex split is denoted vsplit(s, l, r, t, A), where A stores the coordinates of vs, vt, the attributes of the affected corners (all corners at vs and vt, and one corner at vl and vr), and the discrete attributes of the two appearing triangles

41

vl

vr

vs

vt

vl

vr

vs

vsplit

Page 42: Triangle mesh processing

Progressive meshes

• The PM representation is

( M0 , { vsplit0, vsplit1, … , vsplitn-1 } )

where vspliti is the representation of the i-th vertex split

42

Page 43: Triangle mesh processing

Progressive meshes

43

Page 44: Triangle mesh processing

Progressive meshes

44

Page 45: Triangle mesh processing

PM: geomorph

• The PM representation allows morphing between two meshes of different coarseness, say, Mp and Mq with 0 p < q n (called geomorphs)

• Every vertex in Mp also occurs in Mq

• Every vertex in Mq that does not occur in Mp has some ancestor in Mp, a vertex in Mp into which it was (eventually) merged

(vt gets vs as ancestor in the example edge collapse, and whenever vs gets an ancestor later, then vt gets that ancestor too)

45

Page 46: Triangle mesh processing

PM: geomorph

• In a morph with parameter 0 1, we want M(0) to be Mp and M(1) to be Mq and M() to be something in between, interpolating smoothly with

• We see Mp as the mesh structurally the same as Mq and the vertices that were not in Mp are at the location of their ancestor in Mq

• The morph moves every vertex in Mp from its location in Mp to its location in Mq by linear interpolation, for example

46

Page 47: Triangle mesh processing

PM: progressive transmission

• Straightforward:– first transmit the base mesh M0

– then transmit the vsplits in sequence vsplit0, vsplit1, … – the receiving process builds the mesh while vsplits arrive– geomorphs can be used to have smooth transitions, e.g.,

a base mesh with 100 vertices could morph to the next after 100 vsplits, then to next after another 200 vsplits, then after another 400, etc. (exponentially growing)

47

Page 48: Triangle mesh processing

PM: compression

• Various tricks are possible, see the paper by Hoppe

48

Page 49: Triangle mesh processing

PM: selective refinement

• Apply vsplits only in regions where more detail is needed (e.g., close to the viewpoint)

• In particular, perform a vsplit if– the three vertices vs, vl, and vr are present in the mesh– the vsplit is in a region where more detail is desired

49

Page 50: Triangle mesh processing

PM construction

• Done off-line so need not be very fast• Done in two steps:– detailed mesh construction (from a given initial mesh)– mesh simplification (choice of edge collapse sequence)

50

Page 51: Triangle mesh processing

PM construction, detailed mesh

• To achieve quality, it can be phrased as an optimization of some measure

• Minimize energy in:

E(M) = Edist(M) + Erep(M) + Espring(M)

1st term: geometric accuracy (original mesh to mesh M)2nd term: conciseness (no. of vertices in mesh)3rd term: regularity (unify edge lengths)

51

Page 52: Triangle mesh processing

PM construction, detailed mesh

• E(M) = Edist(M) + Erep(M) + Espring(M)

• Edist(M) = , the sum of squared distances from the points X = { x1, x2, … } sampled densely on the original mesh to the mesh M

• Erep(M) = crep m, a constant times the number of mesh vertices

• Espring(M) = , the sum over all edges of the length times a spring constant , rest length of spring is zero

52

Page 53: Triangle mesh processing

PM construction, detailed mesh

• Minimization of energy in two nested loops• Outer loop: change connectivity by randomly trying

edge collapse, edge split, and edge flip– Inner loop: for a chosen attempt, optimize the vertex

locations (minimize Edist(M) + Espring(M) )

• If the new mesh has smaller energy, then accept the connectivity change

53

Page 54: Triangle mesh processing

PM construction, detailed mesh

• Initial mesh to approximate: sample many points on the faces and add all vertices of the initial mesh, then run the energy minimizing mesh optimization to get the detailed mesh

• Different values of crep give rise to a trade-off between mesh size and mesh accuracy

54

Page 55: Triangle mesh processing

PM construction, edge collapse

• Minimize energy in:

E(M) = Edist(M) + Espring(M) + Escalar(M) + Edisc(M)

1st term: geometric accuracy (distance points to mesh)2nd term: regularity (unify edge lengths)3rd term: accuracy of scalar attributes4th term: accuracy of discontinuity curves

First two terms: same as for detailed mesh construction

Page 56: Triangle mesh processing

PM construction, edge collapse

• Hoppe claims that edge collapse is sufficient to obtain good meshes of every size (detail level);edge flip and edge split are not needed

• The fact that only edge collapse is used gives rise to the PM representation and its simplicity

56

Page 57: Triangle mesh processing

PM construction, edge collapse

• Any edge collapse turns a mesh with connectivity K into a mesh with connectivity K’

• For any edge collapse we can compute its minimum energy by optimizing over vertex positions and scalar attribute assignment at the affected corners

• E = E(K’) – E(K) • Repeatedly choose the edge collapse minimizing E

(equivalent: minimizing E(K’) )

57

Page 58: Triangle mesh processing

PM construction, edge collapse

• When performing an edge collapse, we optimize the location of the merged vertex vs only

• Then only the candidate edge collapses around vs need to re-compute their energy difference E (all edges of triangles incident to vs)

58

vl

vr

vs

vt

vl

vr

vs

Page 59: Triangle mesh processing

PM construction, edge collapse

• Use a priority queue storing all possible edge collapses, with E as their priority (illegal edge collapses are not stored)

• ExtractMin gives the next edge to collapse• Re-computation (delete and re-insert in the priority

queue) is needed for the affected edges only, typically only O(1) of them

• Cross-pointers between the mesh and the priority queue are needed for efficiency

59

Page 60: Triangle mesh processing

PM construction, edge collapse

60

priority queue

mesh

Page 61: Triangle mesh processing

PM construction, edge collapse

• When computing the energy part Edist(M) + Espring(M) for a possible edge collapse, the new vertex position of vs is tried at three places: at vs, vt, and halfway

• Only the points of X (representing the original mesh by a dense sample of points) that project onto the triangles involved in the collapse are tested and affect Edist(M)

61

edge collapsevs vtvs

points of X

Page 62: Triangle mesh processing

PM construction, edge collapse

• For the energy term Escalar(M), recall that scalar values are stored with corners of the mesh

• We can estimate the scalar values at all points of X by interpolation of the corners, and use these values at X to define Escalar(M) as a distance in scalar values

• Scalar values at new corners can be assigned by optimization

62

edge collapsevs vtvs

points of X

Page 63: Triangle mesh processing

PM construction, edge collapse

• For the energy term Edisc(M), use discontinuity curves: material boundaries, color (discrete), or creases (non-smooth changes on the surface; scalar)

change in material

creases

63

Page 64: Triangle mesh processing

PM construction, edge collapse

• Forbid or penalize changes in the topology of discontinuity curves

• Choose set of points Y (like X) close to discontinuity curves of the original mesh, to use for the energy Edisc(M) that measures how close those points are to the discontinuity curves of the evaluated mesh M

64

Page 65: Triangle mesh processing

PM construction, edge collapse

65

edge collapses that change the topology

points of Y

Page 66: Triangle mesh processing

PM construction, edge collapse

• The four energies, and the testing of all edge collapses, optimizing the vertex position of vs, determines which edge collapse is next in the (inverted) vsplit sequence of the PM

66

Page 67: Triangle mesh processing

Summary

• Mesh processing is about mesh simplification, mesh improvement, mesh hierarchies, measures for quality

• Mesh processing involves many more aspects: mesh repair, mesh deformation, mesh animation, …

• Hoppe’s scheme is interesting because it provides a hierarchy, and because it takes scalar and discrete values into account explicitly

67