1.2 Surface Representation & Data Structures Hao Li - - PowerPoint PPT Presentation

1 2 surface representation data structures
SMART_READER_LITE
LIVE PREVIEW

1.2 Surface Representation & Data Structures Hao Li - - PowerPoint PPT Presentation

Spring 2019 CSCI 621: Digital Geometry Processing 1.2 Surface Representation & Data Structures Hao Li http://cs621.hao-li.com 1 Last Time Geometry Processing Reconstruction Rendering Capture Analysis Reproduction Manipulation 2


slide-1
SLIDE 1

CSCI 621: Digital Geometry Processing

Hao Li

http://cs621.hao-li.com

1

Spring 2019

1.2 Surface Representation & Data Structures

slide-2
SLIDE 2

Last Time

2

Reconstruction Geometry Processing Capture Analysis Manipulation Rendering Reproduction

slide-3
SLIDE 3

Geometric Representations

3

implicit surfaces / particles volumetric tetrahedrons point based quad mesh triangle mesh

slide-4
SLIDE 4

Geometric Representations

4

implicit surfaces / particles volumetric tetrahedrons point based quad mesh triangle mesh

Surface Representations

slide-5
SLIDE 5

High Resolution

5

slide-6
SLIDE 6

Large scenes

6

slide-7
SLIDE 7

Outline

7

  • Parametric Approximations
  • Polygonal Meshes
  • Data Structures
slide-8
SLIDE 8

Parametric Representation

8

r

f : Ω ⊂ IR2 → IR3, SΩ = f(Ω) f : [0, 2π] → IR2 f(t) =

  • r cos(t)

r sin(t) ⇥

Surface is the range of a function 2D example: A Circle

slide-9
SLIDE 9

Parametric Representation

9

f : Ω ⊂ IR2 → IR3, SΩ = f(Ω) f : [0, 2π] → IR2 f(t) =

  • r cos(t)

r sin(t) ⇥

Surface is the range of a function 2D example: Island coast line ? ?

slide-10
SLIDE 10

Piecewise Approximation

10

f : Ω ⊂ IR2 → IR3, SΩ = f(Ω) f : [0, 2π] → IR2 f(t) =

  • r cos(t)

r sin(t) ⇥

Surface is the range of a function 2D example: Island coast line ? ?

slide-11
SLIDE 11

Polynomial Approximation

11

f(t) =

p

  • i=0

ci ti =

p

  • i=0

˜ ci φi(t) f(ti) = g(ti) , 0 ≤ t0 < · · · < tp ≤ h |f(t) − g(t)| ≤ 1 (p + 1)! max f (p+1)

p

i=0

(t − ti) = O

  • h(p+1)⇥

g(h) =

p

i=0

1 i! g(i)(0) hi + O

  • hp+1⇥

Polynomials are computable functions Taylor expansion up to degree Error for approximation by polynomial

p g f

slide-12
SLIDE 12

Polynomial Approximation

12

Improve approximation quality by

  • increasing … higher order polynomials
  • decreasing … shorter / more segments

Issues

  • smoothness of the target data ( )
  • smoothness condition between segments

Approximation error is O(hp+1)

h p max

t

f (p+1)(t)

slide-13
SLIDE 13

Polygonal Meshes

13

3 6 12 24

Polygonal meshes are a good compromise

  • Piecewise linear approximation → error is O(h2)

25% 6.5% 1.7% 0.4%

slide-14
SLIDE 14

Polygonal Meshes

14

Polygonal meshes are a good compromise

  • Piecewise linear approximation → error is
  • Error inversely proportional to #faces

O(h2)

slide-15
SLIDE 15

Polygonal Meshes

15

Polygonal meshes are a good compromise

  • Piecewise linear approximation → error is
  • Error inversely proportional to #faces
  • Arbitrary topology surfaces

O(h2)

slide-16
SLIDE 16

Polygonal Meshes

16

Polygonal meshes are a good compromise

  • Piecewise linear approximation → error is
  • Error inversely proportional to #faces
  • Arbitrary topology surfaces
  • Piecewise smooth surfaces

O(h2)

slide-17
SLIDE 17

Polygonal Meshes

17

Polygonal meshes are a good compromise

  • Piecewise linear approximation → error is
  • Error inversely proportional to #faces
  • Arbitrary topology surfaces
  • Piecewise smooth surfaces
  • Adaptive sampling

O(h2)

slide-18
SLIDE 18

Polygonal Meshes

18

Polygonal meshes are a good compromise

  • Piecewise linear approximation → error is
  • Error inversely proportional to #faces
  • Arbitrary topology surfaces
  • Piecewise smooth surfaces
  • Adaptive sampling
  • Efficient GPU-based rendering/processing

O(h2)

slide-19
SLIDE 19

Outline

19

  • Parametric Approximations
  • Polygonal Meshes
  • Data Structures
slide-20
SLIDE 20

Graph Definitions

20

A B C D E F G H I J K

  • Graph {V,E}
slide-21
SLIDE 21

21

A B C D E F G H I J K

Graph Definitions

  • Graph {V,E}
  • Vertices V = {A,B,C,…,K}
slide-22
SLIDE 22

22

A B C D E F G H I J K

Graph Definitions

  • Graph {V,E}
  • Vertices V = {A,B,C,…,K}
  • Edges E = {(AB),(AE),(CD),…}
slide-23
SLIDE 23

23

A B C D E F G H I J K

Graph Definitions

  • Graph {V,E}
  • Vertices V = {A,B,C,…,K}
  • Edges E = {(AB),(AE),(CD),…}
  • Faces F = {(ABE),(EBF),(EFIH),…}
slide-24
SLIDE 24

24

A B C D E F G H I J K

Graph Definitions

Vertex degree or valence: number of incident edges

  • deg(A) = 4
  • deg(E) = 5
slide-25
SLIDE 25

25

A B C D E F G H I J K

Connectivity

Connected:

Path of edges connecting every two vertices

slide-26
SLIDE 26

Connectivity

26

A B C D E F G H I J K

Connected:

Path of edges connecting every two vertices

Subgraph:

Graph {V’,E’} is a subgraph of graph {V,E} if V’ is a subset of V and E’ is a subset of E incident on V’.

slide-27
SLIDE 27

Connectivity

27

A B C D E F G H I J K

Connected:

Path of edges connecting every two vertices

Subgraph:

Graph {V’,E’} is a subgraph of graph {V,E} if V’ is a subset of V and E’ is a subset of E incident on V’.

slide-28
SLIDE 28

Connectivity

28

A B C D E F G H I J K

Connected:

Path of edges connecting every two vertices

Subgraph:

Graph {V’,E’} is a subgraph of graph {V,E} if V’ is a subset of V and E’ is a subset of E incident on V’.

Connected Components:

Maximally connected subgraph

slide-29
SLIDE 29

Connectivity

29

A B C D E F G H I J K

Connected:

Path of edges connecting every two vertices

Subgraph:

Graph {V’,E’} is a subgraph of graph {V,E} if V’ is a subset of V and E’ is a subset of E incident on V’.

Connected Components:

Maximally connected subgraph

slide-30
SLIDE 30

Graph Embedding

30

Embedding: Graph is embedded in , if each vertex is assigned a position in .

Embedding in Embedding in

Rd Rd R2 R3

slide-31
SLIDE 31

Graph Embedding

31

Embedding: Graph is embedded in , if each vertex is assigned a position in .

Embedding in R3

Rd Rd

slide-32
SLIDE 32

32

Planar Graph

Planar Graph

Graph whose vertices and edges can be embedded in such that its edges do not intersect

Planar Graph Plane Graph Straight Line Plane Graph

R2

slide-33
SLIDE 33

Triangulation

33

A B C D E F G H I J K

Triangulation:

Straight line plane graph where every face is a triangle

Why?

  • simple homogenous data structure
  • efficient rendering
  • simplifies algorithms
  • by definition, triangle is planar
  • any polygon can be triangulated
slide-34
SLIDE 34

Mesh

34

  • Mesh: straight-line graph

embedded in

  • Boundary edge: adjacent to

exactly 1 face

  • Regular edge: adjacent to

exactly 2 faces

  • Singular edge: adjacent to

more than 2 faces

  • Closed mesh: mesh with no

boundary edges

R3

slide-35
SLIDE 35

Polygon

35

A geometric graph with in , and is called a polygon A polygon is called

  • flat, if all edges are on a plane
  • closed, if

Q = (V, E) V = {p0, p1, . . . , pn−1} Rd d ≥ 2 E = {(p0, p1) . . . (pn−2, pn−1)} p0 = pn−1

slide-36
SLIDE 36

While digital artists call it Wireframe, …

36

slide-37
SLIDE 37

Polygonal Mesh

37

A set of finite number of closed polygons if:

  • Intersection of inner polygonal areas is empty
  • Intersection of 2 polygons from is either empty, a point
  • r an edge
  • Every edge belongs to at least one polygon
  • The set of all edges which belong only to one polygon are

called edges of the polygonal mesh and are either empty or form a single closed polygon

M Qi M e ∈ E p ∈ P e ∈ E

slide-38
SLIDE 38

Polygonal Mesh Notation

38

vi ∈ R3

M = ({vi}, {ej}, { fk})

geometry

slide-39
SLIDE 39

Polygonal Mesh Notation

39

ei, fi ⊂ R3 topology vi ∈ R3

M = ({vi}, {ej}, { fk})

geometry

slide-40
SLIDE 40

Global Topology: Genus

40

  • Genus: Maximal number of closed simple cutting

curves that do not disconnect the graph into multiple components.

  • Or half the maximal number of closed paths that do

no disconnect the mesh

  • Informally, the number of holes or handles

Genus 0 Genus 1 Genus 2 Genus 3

slide-41
SLIDE 41

Euler Poincaré Formula

41

  • For a closed polygonal mesh of genus , the relation
  • f the number of vertices, of edges, and of faces

is given by Euler’s formula:

  • The term is called the Euler characteristic

g V E F V − E + F = 2(1 − g) 2(1 − g) χ

slide-42
SLIDE 42

Euler Poincaré Formula

42

V − E + F = 2(1 − g) 4 − 6 + 4 = 2(1 − 0)

slide-43
SLIDE 43

Euler Poincaré Formula

43

16 − 32 + 16 = 2(1 − 1) V − E + F = 2(1 − g)

slide-44
SLIDE 44

Average Valence of Closed Triangle Mesh

44

Theorem: Average vertex degree in a closed manifold triangle mesh is ~6 Proof: Each face has 3 edges and each edge is counted twice: 3F = 2E by Euler’s formula: V+F-E = V+2E/3-E = 2-2g Thus E = 3(V-2+2g) So average degree = 2E/V = 6(V-2+2g)/V ~6 for large V

slide-45
SLIDE 45

Euler Consequences

45

Triangle mesh statistics

  • Average valence = 6

Quad mesh statistics

  • Average valence = 4

F ≈ 2V E ≈ 3V F ≈ V E ≈ 2V

slide-46
SLIDE 46

Euler Characteristic

46

Sphere Torus Moebius Strip Klein Bottle

χ = 2 χ = 0 χ = 0 χ = 0

slide-47
SLIDE 47

How many pentagons?

47

slide-48
SLIDE 48

How many pentagons?

48

Any closed surface of genus 0 consisting only of hexagons and pentagons and where every vertex has valence 3 must have exactly 12 pentagons

slide-49
SLIDE 49

Two-Manifold Surfaces

49

Local neighborhoods are disk-shaped Guarantees meaningful neighbor enumeration

  • required by most algorithms

Non-manifold Examples:

f(D✏[u, v]) = D[f(u, v)]

slide-50
SLIDE 50

Outline

50

  • Parametric Approximations
  • Polygonal Meshes
  • Data Structures
slide-51
SLIDE 51

Mesh Data Structures

51

  • How to store geometry & connectivity?
  • compact storage and file formats
  • Efficient algorithms on meshes
  • Time-critical operations
  • All vertices/edges of a face
  • All incident vertices/edges/faces of a vertex
slide-52
SLIDE 52

Data Structures

52

What should be stored?

  • Geometry: 3D vertex coordinates
  • Connectivity: Vertex adjacency
  • Attributes:
  • normals, color, texture coordinates, etc.
  • Per Vertex, per face, per edge
slide-53
SLIDE 53

Data Structures

53

What should it support?

  • Rendering
  • Queries
  • What are the vertices of face #3?
  • Is vertex #6 adjacent to vertex #12?
  • Which faces are adjacent to face #7?
  • Modifications
  • Remove/add a vertex/face
  • Vertex split, edge collapse
slide-54
SLIDE 54

Data Structures

54

Different Data Structures:

  • Time to construct (preprocessing)
  • Time to answer a query
  • Random access to vertices/edges/faces
  • Fast mesh traversal
  • Fast Neighborhood query
  • Time to perform an operation
  • split/merge
  • Space complexity
  • Redundancy
slide-55
SLIDE 55

Data Structures

55

Different Data Structures:

  • Different topological data storage
  • Most important ones are face and edge-based

(since they encode connectivity)

  • Design decision ~ memory/speed trade-off
slide-56
SLIDE 56

Face Set (STL)

56

Triangles x11 y11 z11 x12 y12 z12 x13 y13 z13 x21 y21 z21 x22 y22 z22 x23 y23 z23 ... ... ... xF1 yF1 zF1 xF2 yF2 zF2 xF3 yF3 zF3

Face:

  • 3 vertex positions

9*4 = 36 B/f (single precision) 72 B/v (Euler Poincaré) No explicit connectivity

slide-57
SLIDE 57

Shared Vertex (OBJ,OFF)

57

Vertices x1 y1 z1 ... xV yV zV Triangles i11 i12 i13 ... ... ... ... iF1 iF2 iF3

12 B/v + 12 B/f = 36B/v No explicit adjacency info

Indexed Face List:

  • Vertex: position
  • Face: Vertex Indices
slide-58
SLIDE 58

Face-Based Connectivity

58

64 B/v No edges: Special case handling for arbitrary polygons

Vertex:

  • position
  • 1 face

Face:

  • 3 vertices
  • 3 face neighbors
slide-59
SLIDE 59

Edges always have the same topological structure

59

Efficient handling of polygons with variable valence

slide-60
SLIDE 60

(Winged) Edge-Based Connectivity

60

Vertex:

  • position
  • 1 edge

Edge:

  • 2 vertices
  • 2 faces
  • 4 edges

Face:

  • 1 edges

120 B/v Edges have no orientation: special case handling for neighbors

slide-61
SLIDE 61

Halfedge-Based Connectivity

61

96 to 144 B/v Edges have orientation: No- runtime overhead due to arbitrary faces

Vertex:

  • position
  • 1 halfedge

Edge:

  • 1 vertex
  • 1 face
  • 1, 2, or 3 halfedges

Face:

  • 1 halfedge
slide-62
SLIDE 62

Arbitrary Faces during Modeling

62

slide-63
SLIDE 63

One-Ring Traversal

63

  • 1. Start at vertex
slide-64
SLIDE 64

One-Ring Traversal

64

  • 1. Start at vertex
  • 2. Outgoing halfedge
slide-65
SLIDE 65

One-Ring Traversal

65

  • 1. Start at vertex
  • 2. Outgoing halfedge
  • 3. Opposite halfedge
slide-66
SLIDE 66

One-Ring Traversal

66

  • 1. Start at vertex
  • 2. Outgoing halfedge
  • 3. Opposite halfedge
  • 4. Next halfedge
slide-67
SLIDE 67

One-Ring Traversal

67

  • 1. Start at vertex
  • 2. Outgoing halfedge
  • 3. Opposite halfedge
  • 4. Next halfedge
  • 5. Opposite
slide-68
SLIDE 68

One-Ring Traversal

68

  • 1. Start at vertex
  • 2. Outgoing halfedge
  • 3. Opposite halfedge
  • 4. Next halfedge
  • 5. Opposite
  • 6. Next
  • 7. …
slide-69
SLIDE 69

Halfedge datastructure Libraries

69

CGAL

  • www.cgal.org
  • Computational Geometry
  • Free for non-commercial use

OpenMesh

  • www.openmesh.org
  • Mesh processing
  • Free, LGPL license
slide-70
SLIDE 70

Why Openmesh?

70

Flexible / Lightweight

  • Random access to vertices/edges/faces
  • Arbitrary scalar types
  • Arrays or lists as underlying kernels

Efficient in space and time

  • Dynamic memory management for array-based

meshes (not in CGAL)

  • Extendable to specialized kernels for non-manifold

meshes (not in CGAL)

Easy to Use

slide-71
SLIDE 71

Literature

71

  • Textbook: Chapter
  • http://www.openmesh.org
  • Kettner, Using generic programming for designing a data structure

for polyhedral surfaces, Symp. on Comp. Geom., 1998

  • Campagna et al., Directed Edges - A Scalable Representation for

Triangle Meshes, Journal of Graphics Tools 4(3), 1998

  • Botsch et al., OpenMesh - A generic and efficient polygon mesh data

structure, OpenSG Symp. 2002

slide-72
SLIDE 72

TODO

72

Learn the terms and notations

slide-73
SLIDE 73

Next Next Time

73

  • Explicit & Implicit Surfaces
  • Exercise 1: Getting Started with Mesh Processing
slide-74
SLIDE 74

http://cs621.hao-li.com

Thanks!

74