1 / 49

Mesh Representation, part I

Mesh Representation, part I. based on: Data Structures for Graphics , chapter 12 in Fundamentals of Computer Graphics, 3 rd ed. (Shirley & Marschner ). 3D objects. A single 3D object has a volume that is bounded by 2-dimensional patches (surfaces)

mikel
Télécharger la présentation

Mesh Representation, part I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mesh Representation, part I based on: Data Structures for Graphics, chapter 12 in Fundamentals of Computer Graphics, 3rd ed. (Shirley & Marschner)

  2. 3D objects • A single 3D object has a volume that is bounded by 2-dimensional patches (surfaces) • These 2-dimensional boundary patches are bounded by 1-dimensional features (curves or edges) • These 1-dimensional features are bounded by 0-dimensional things (points, called vertices)

  3. 3D objects facets edges vertices

  4. 3D objects • We typically represent the boundary; the interior is implied to be the bounded subspace • We will assume linear boundaries here, so we have facets, edges, and vertices (and the interior)

  5. Triangle meshes • Many freeform shapes consist of (many) triangles

  6. Triangle meshes • How are triangles, edges, and vertices allowed to connect? • How do we represent (store) triangle meshes? • How efficient are such schemes?

  7. Manifolds • A manifold is “watertight”: the interior is separated from the exterior everywhere • Very locally at every point on the manifold, it “looks like” the very local situation on a sphere

  8. Manifolds • A manifold is “watertight”: the interior is separated from the exterior everywhere • Very locally at every point on the manifold, it “looks like” the very local situation on a sphere

  9. Manifolds • Technically, we are discussing a 2-manifold in 3D • For any point on the 2-manifold, consider an arbitrarily small sphere centered at that point, and intersect the sphere boundary with the 2-manifold: this should be one closed loop

  10. Manifolds

  11. Manifolds not a manifold manifold

  12. Triangle meshes for manifolds • A triangle mesh can be a manifold only if the following two local conditions are satisfied • Every edge is shared by exactly two triangles • Every vertex has a single, complete loop of triangles around it • A global condition is that the manifold does not self-intersect

  13. Manifolds with boundary • A disk in 3D space is a manifold with boundary; the boundary is a circle • Any surface or surface patch is a manifold with boundary if • very locally at any point p, itis like how it is very locally at some point on a disk (boundary circle or interior) the neighborhood of p is a single closed loop or one non-closed curve

  14. Manifolds with boundary

  15. Manifolds with boundary • Manifolds with boundary are not necessarily watertight • Self-intersecting surfaces cannot be manifolds with (nor without) boundary • Surfaces with parts that are thin tentacles cannot be manifolds with (nor without) boundary

  16. Triangle meshes for manifolds with boundary • A triangle mesh can be a manifold with boundary only if the following two local conditions are satisfied • Every edge is shared by one or two triangles • Every vertex connects to a single edge-connected set of triangles • A global condition is that the manifold does not self-intersect

  17. Triangle meshes • For manifolds with or without boundary • Store triangles • Store coordinates of vertices • Possibly store edges, adjacencies of triangles, etc., depending on the scheme 9 vertices, 16 edges, and 8 triangles in a triangle mesh

  18. Triangle meshes • Features of the same dimensionality are adjacent or not (two vertices, or two edges, or two triangles) • Features of different dimensionality are incident or not (vertex-edge, vertex-triangle, edge-triangle) adjacent triangles adjacent vertices adjacent edges

  19. Triangle meshes • Features of the same dimensionality are adjacent or not (two vertices, or two edges, or two triangles) • Features of different dimensionality are incident or not (vertex-edge, vertex-triangle, edge-triangle) non-adjacent triangles non-adjacent vertices non-adjacent edges

  20. Triangle meshes • Features of the same dimensionality are adjacent or not (two vertices, or two edges, or two triangles) • Features of different dimensionality are incident or not (vertex-edge, vertex-triangle, edge-triangle) incident edge and triangle incident edge and vertex incident vertex and triangle

  21. Triangle meshes • Features of the same dimensionality k>0 are adjacent if and only if their boundaries (or their closures) contain the same feature of dimensionality k – 1 • Vertices are adjacent if they are endpoints of some edge (incident on a common edge) • Features of different dimensionality are incident if the feature with lower dimensionality is a subset of the boundary (or closure) of the feature with higher dimensionality

  22. Orientation of triangles • By convention, triangles of a manifold are oriented so that from the outside, the triangle is counter-clockwise (and seen from the inside it is clockwise) Orientation is not needed for representation, but it may be convenient for coding to use a consistent orientation

  23. Orientation of triangles • For a manifold with boundary, we can define a front and a back where the front has triangles oriented counter-clockwise • This only works for orientable surfaces with boundary Möbius strip

  24. Non-orientable surfaces Klein bottle Möbius strip non-orientable surface without boundary

  25. Triangle mesh schemes (simple) • Separate triangles mesh • Shared vertex mesh • Indexed triangle mesh • ....

  26. Separate triangles mesh • Each triangle is an object that stores the coordinates of its vertices the same coordinates are stored multiple times v6 T1 (x1,y1,z1) (x5,y5,z5) (x6,y6,z6) v1 v7 (x1,y1,z1) T2 (x2,y2,z2) (x5,y5,z5) T1 T6 T5 T2 v5 T3 (x2,y2,z2) (x3,y3,z3) (x5,y5,z5) v2 T7 T3 T4 v8 v4     v3  

  27. Shared vertex mesh • Each vertex is an object that stores its coordinates • Each triangle is an object that stores references to its vertices v1 (x1,y1,z1) v2 (x2,y2,z2) v6 v3 (x3,y3,z3) v1 v7 T1 T1 T6 v1 v5 v6 T5 T2 v5 v2 T7 v1 T2 v2 v5 T3 T4 v8 v4 v2 T3 v3 v5       v3   

  28. Indexed triangle mesh • Same as shared vertex mesh but the j-th vertex of the i-th triangle is addressed as Array[ i][ j ], j = 1,2,3 and i = 1,2, ..., no. of triangles v1 (x1,y1,z1) v2 (x2,y2,z2) A[1][1] = 1 A[1][2] = 5 A[1][3] = 6 A[2][1] = 1 A[2][2] = 2 A[2][3] = 5 v6 v3 (x3,y3,z3) v1 v7 T1 T6 T5 T2 v5 v2 T7 T3 T4 v8 v4     v3  

  29. Comparison of simple meshes • Assume same storage for floats, ints, and pointers: • Separate triangles mesh: 9 nt units for nt triangles • Other two: 3 nv + 3 nt units for nv vertices and nt triangles • In meshes we roughly have: nt 2 nvWhy? • All triangles have 3 edges, and most of the edges are incident to 2 triangles. So 3 nt  2 ne • Euler’s formula for connected planar graphs statesnv – ne + nt = 2

  30. Comparison of simple meshes • Assume same storage for floats, ints, and pointers: • Separate triangles mesh: 9 nt units for nt triangles • Other two: 3 nv + 3 nt units for nv vertices and nt triangles • In meshes we roughly have: nt 2 nv • Separate triangles mesh:  18 nv units of storage • Shared or indexed mesh:  9 nv units of storage

  31. In-memory versus transfer • Indexed triangle meshes are the most common in-memory representation of triangle meshes • For transferring meshes, triangle fans and triangle strips can save bandwidth v12 v6 T11 v1 v7 T1 T6 T5 v11 T2 T12 v5 v4 v2 T7 T3 T4 v8 T10 T9 T8 v3 v10 v9

  32. In-memory versus transfer Indexed triangle meshes are the most common in-memory representation of triangle meshes For transferring meshes, triangle fans and triangle strips can save bandwidth v12 v6 indexed mesh: T11 v1 v7 345, 465, 647, 487 T1 T6 T5 v11 T2 T12 v5 v4 v2 T7 triangle fan T3 T4 v8 T10 435678 means triangles with fan center at 4 and sequence 35678 T9 T8 v3 v10 v9

  33. In-memory versus transfer Indexed triangle meshes are the most common in-memory representation of triangle meshes For transferring meshes, triangle fans and triangle strips can save bandwidth v12 v6 indexed mesh: T11 v1 v7 345, 465, 647, 487 T1 T6 T5 v11 T2 T12 v5 v4 v2 T7 triangle strip T3 T4 v8 T10 235467(12) means first triangle 235, then 35 with 4, then 54 with 6, then 46 … T9 T8 v3 v10 v9

  34. In-memory versus transfer Triangle fans/strips use k+2 indices for a fan/strip with k triangles; an indexed mesh would use 3k indices We need a decomposition of the mesh into fans or strips Strips are often long, fans seldom v12 v6 T11 v1 v7 v11 T1 T6 T5 T2 T12 v5 v4 v2 T7 T3 T4 v8 T10 T9 T8 v3 v10 v9

  35. Model with triangle strips shown

  36. Efficiency of triangle strips • Suppose a surface with n triangles can be represented using m triangle strips, then we need n + 2m indicesavg strip length 4 5 6 7 8indices per triangle 1.5 1.4 1.33 1.29 1.25without strips 3 3 3 3 3 • Minimizing the number of strips is basically a puzzle

  37. Connectivity structures for meshes • Let triangles have direct access to the adjacent triangles • Allows efficient editing of the mesh • Allows neighborhoods on the mesh to be explored efficiently • Allows paths on the mesh to be followed efficiently v12 v6 T11 v1 v7 T1 T6 T5 T2 v5 v4 v2 T7 T3 T4 v8 T10 T9 T8 v3 v10 v9

  38. Connectivity structures for meshes • Let triangles have direct access to the adjacent triangles • Allows efficient editing of the mesh • Allows neighborhoods on the mesh to be explored efficiently • Allows paths on the mesh to be followed efficiently • In an indexed mesh, how do you find the three vertices“opposite” a triangle?(v1, v3, and v7 for the shown triangle) v12 v6 T11 v1 v7 T1 T6 T5 T2 v5 v4 v2 T7 T3 T4 v8 T10 T9 T8 v3 v10 v9

  39. Triangle neighbor structure • Take the shared vertex mesh and add a pointer from each triangle to the three adjacent triangles • Optional: let each vertex have a pointer to one incident triangle nbr[2] v[0] Triangle { Triangle nbr[3] Vertex v[3] … } v[2] nbr[0] nbr[1] v[1]

  40. Triangle neighbor structure • For manifolds with boundary, a triangle at the boundary will have one of its nbr[.] point to NIL, or use index –1 to reference a neighbor(a triangle can also have two edges that are on the boundary of the manifold)

  41. Triangle neighbor structure • How do you find the three vertices opposite a triangle t? • The adjacent triangles are directly accessed ast.nbr[0], t.nbr[1], and t.nbr[2] • For t.nbr[0], we determinethe vertex that is not equal to t.v[0] or t.v[1] • For t.nbr[1] and t.nbr[2] itis analogous v12 v6 T11 v1 v7 T1 T6 T5 T2 v5 v4 v2 T7 T3 T4 v8 T10 T9 T8 v3 v10 v9

  42. Triangle neighbor structure • Expressed in algorithmic efficiency notation: • In an indexed mesh, finding opposite vertices for a triangle takes linear time in the mesh size, O(n) • In a triangle neighbor structure, finding opposite vertices takes constant time (independent of mesh size), O(1)

  43. Triangle neighbor structure • Storage usage expressed in number of vertices nv: • An indexed mesh uses 9 nv units of storage • A triangle neighbor structure uses 15 nv units of storage(a triangle uses 6 units and a vertex uses 3 units, and there are roughly twice as many triangles as vertices)

  44. Questions: height profile • A triangle mesh can be used to represent a terrain, where the third coordinate is height above sea level.How efficiently can you compute a height profile, a cross-section with a given vertical plane • using an indexed mesh? • using a triangle neighbor structure?

  45. Winged-edge structure • Stores connectivity at edges instead of triangles • For one edge, say, e1: • Two vertices are important: v4 and v6 • Two triangles are important: T5 and T6 • Four edges are important: e2, e14, e5, and e8 v6 e7 e8 v1 v7 e14 T1 T6 e3 e12 e1 T5 e10 T2 v5 e5 v2 T7 e9 e2 e4 T3 T4 e6 v8 e11 v4 e13 v3

  46. Winged-edge structure • Give e1 a direction, then • v4 is the tail and v6 is the head • T5 is to the left and T6 is to the right • e2 is previous on the left side, e14 is next on the left side, e5 is previous on the right side, and e8 is next on the right side v6 e7 e8 v1 v7 e14 T1 T6 e1 e3 e12 T5 e10 T2 v5 e5 v2 T7 e9 e2 e4 T3 T4 e6 v8 e11 v4 e13 v3

  47. Winged-edge structure • Give e1 a direction, then • v4 is the tail and v6 is the head • T5 is to the left and T6 is to the right • e2 is previous on the left side, e14 is next on the left side, e5 is previous on the right side, and e8 is next on the right side head v6 rnext e8 e14 lnext T6 right e1 T5 left e5 rprev e2 lprev v4 tail

  48. Winged-edge structure Edge { Edge lprev, lnext, rprev, rnext; Vertex head, tail; Face left, right } head rnext lnext Vertex { double x, y, z; Edge e; // any incident } right left rprev lprev tail Triangle { Edge e; // any incident }

  49. Questions • The triangle strip savings table shows only the average number of indices when triangle strips have an average length. We must also transfer the vertices themselves. Assuming that indices and coordinates use the same amount of storage, make a table with the total transfer savings when using triangle strips • Analyze how much storage the winged-edge structure needs for a mesh with nv vertices • For a given triangle t, write code for reporting the coordinates of its vertices (winged-edge) • For a given triangle t, write code for reporting the coordinates of the opposite vertices (winged-edge) • For a given vertex v, write code for reporting the coordinates of all the adjacent vertices (winged-edge)

More Related