Spring 2014
CSCI 599: Digital Geometry Processing
1.2 Surface Representation !
& Data Structures
Hao Li
http://cs599.hao-li.com
!1
Administrative
• No class next Tuesday, due to Siggraph deadline!
• Introduction to first programming exercise next
Thursday
Siggraph Deadline 2013@ILM, Ewww!
!2
After Siggraph Deadline @ILM
!3
Last Time
Geometry Processing
Reconstruction
Rendering
Capture Analysis
Reproduction
Manipulation
!4
Geometric Representations
point based quad mesh triangle mesh
implicit surfaces / particles volumetric tetrahedrons
!5
Geometric Representations
point based quad mesh triangle mesh
Surface Representations
implicit surfaces / particles volumetric tetrahedrons
!6
High Resolution
!7
Large scenes
!8
Outline
• Parametric Approximations
• Polygonal Meshes
• Data Structures
!9
Parametric Representation
Surface is the range of a function
f: IR ⇥ IR ,
2 3
S = f( )
2D example: A Circle
f : [0, 2 ] IR 2
⇥
r cos(t) r
f (t) =
r sin(t)
!10
Parametric Representation
Surface is the range of a function
f: IR ⇥ IR ,
2 3
S = f( )
2D example: Island coast line
f : [0, 2 ] IR 2
⇥
r cos(t)
?
f (t) =
r sin(t)
?
!11
Piecewise Approximation
Surface is the range of a function
f: IR ⇥ IR ,
2 3
S = f( )
2D example: Island coast line
f : [0, 2 ] IR 2
⇥
r cos(t)
?
f (t) =
r sin(t)
?
!12
Polynomial Approximation
Polynomials are computable functions
p p
f (t) = ci ti = c̃i i (t)
i=0 i=0
Taylor expansion up to degree p
⇤p
1 (i) ⇥
g(h) = g (0) h + O h
i p+1
i=0
i!
Error for approximation g by polynomial f
f (ti ) = g(ti ) , 0 ⇥ t0 < · · · < tp ⇥ h
1
p
⇤ ⇥
|f (t) g(t)| ⇥ max f (p+1) (t ti ) = O h(p+1)
(p + 1)! i=0
!13
Polynomial Approximation
Approximation error is O(hp+1 )
Improve approximation quality by!
• increasing p… higher order polynomials
• decreasing h … shorter / more segments
Issues!
(p+1)
• smoothness of the target data ( max f (t) )
t
• smothness condition between segments
!14
Polygonal Meshes
Polygonal meshes are a good compromise!
2
• Piecewise linear approximation → error is O(h )
3 6 12 24
25% 6.5% 1.7% 0.4%
!15
Polygonal Meshes
Polygonal meshes are a good compromise!
2
• Piecewise linear approximation → error is O(h )
• Error inversely proportional to #faces
!16
Polygonal Meshes
Polygonal meshes are a good compromise!
2
• Piecewise linear approximation → error is O(h )
• Error inversely proportional to #faces
• Arbitrary topology surfaces
!17
Polygonal Meshes
Polygonal meshes are a good compromise!
2
• Piecewise linear approximation → error is O(h )
• Error inversely proportional to #faces
• Arbitrary topology surfaces
• Piecewise smooth surfaces
!18
Polygonal Meshes
Polygonal meshes are a good compromise!
2
• Piecewise linear approximation → error is O(h )
• Error inversely proportional to #faces
• Arbitrary topology surfaces
• Piecewise smooth surfaces
• Adaptive sampling
!19
Polygonal Meshes
Polygonal meshes are a good compromise!
2
• Piecewise linear approximation → error is O(h )
• Error inversely proportional to #faces
• Arbitrary topology surfaces
• Piecewise smooth surfaces
• Adaptive sampling
• Efficient GPU-based rendering/processing
!20
Outline
• Parametric Approximations
• Polygonal Meshes
• Data Structures
!21
Graph Definitions
B
A
• Graph {V,E}
E
D F
C
I
H
G
J K
!22
Graph Definitions
B
A
• Graph {V,E}
E
D F • Vertices V = {A,B,C,…,K}
C
I
H
G
J K
!23
Graph Definitions
B
A
• Graph {V,E}
E
D F • Vertices V = {A,B,C,…,K}
C
• Edges E = {(AB),(AE),(CD),…}
I
H
G
J K
!24
Graph Definitions
B
A
• Graph {V,E}
E
D F • Vertices V = {A,B,C,…,K}
C
• Edges E = {(AB),(AE),(CD),…}
I
H • Faces F = {(ABE),(EBF),(EFIH),…}
G
J K
!25
Graph Definitions
B
A
E Vertex degree or valence:!
D F
C number of incident edges!
I
• deg(A) = 4
H • deg(E) = 5
G
J K
!26
Connectivity
Connected:!
B
A Path of edges connecting
every two vertices
E
D F
C
I
H
G
J K
!27
Connectivity
Connected:!
B Path of edges connecting
A
every two vertices
E !
D F
C Subgraph:!
I Graph {V’,E’} is a subgraph of graph
H
{V,E} if V’ is a subset of V and E’ is a
G
subset of E incident on V’.
J K
!28
Connectivity
Connected:!
B Path of edges connecting
A
every two vertices
E !
D F
C Subgraph:!
I Graph {V’,E’} is a subgraph of graph
H
{V,E} if V’ is a subset of V and E’ is a
G
subset of E incident on V’.
J K
!29
Connectivity
Connected:!
B Path of edges connecting
A
every two vertices
E !
D F
C Subgraph:!
I Graph {V’,E’} is a subgraph of graph
H
{V,E} if V’ is a subset of V and E’ is a
G
subset of E incident on V’.
!
J K
Connected Components:!
Maximally connected subgraph
!30
Connectivity
Connected:!
B Path of edges connecting
A
every two vertices
E !
D F
C Subgraph:!
I Graph {V’,E’} is a subgraph of graph
H
{V,E} if V’ is a subset of V and E’ is a
G
subset of E incident on V’.
!
J K
Connected Components:!
Maximally connected subgraph
!31
Graph Embedding
d
Embedding: Graph is embedded in , if R
d
each vertex is assigned a position in R .
2
Embedding in R Embedding in R 3
!32
Graph Embedding
d
Embedding: Graph is embedded in , if R
d
each vertex is assigned a position in R .
3
Embedding in R
!33
Planar Graph
Planar Graph !
Graph whose vertices and edges can be
2
embedded in R such that its edges do
not intersect
Straight Line !
Planar Graph Plane Graph
Plane Graph
!34
Triangulation
Triangulation:!
B Straight line plane graph where every
A face is a triangle
E
D F Why?!
C
• simple homogenous data structure
I
H • efficient rendering
G
• simplifies algorithms
• by definition, triangle is planar
J K • any polygon can be triangulated
!35
Mesh
• Mesh: straight-line graph
3
embedded in R
• 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
!36
Polygon
A geometric graph Q = (V, E)
with V = {p0 , p1 , . . . , pn 1 } in Rd , d 2
and E = {(p0 , p1 ) . . . (pn 2 , pn 1 )}
is called a polygon
!
!
!
!
A polygon is called
• flat, if all edges are on a plane
• closed, if p0 = pn 1
!37
While digital artists call it Wireframe, …
!38
Polygonal Mesh
A set M of finite number of closed polygons Qi if:!
• Intersection of inner polygonal areas is empty
• Intersection of 2 polygons from M is either empty, a point p 2 P
or an edge e 2 E
• Every edge e 2 E 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
!39
Polygonal Mesh Notation
M = ({vi }, {e j }, { f k })
3
geometry vi R
!40
Polygonal Mesh Notation
M = ({vi }, {e j }, { f k })
3
geometry vi R
3
topology ei , f i R
!41
Global Topology: Genus
• 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
!42
Euler Poincaré Formula
• For a closed polygonal mesh of genus g , the relation
of the number V of vertices, E of edges, and F of faces
is given by Euler’s formula:!
!
!
V E + F = 2(1 g)
!
!
• The term 2(1 g) is called the Euler characteristic
!43
Euler Poincaré Formula
V E + F = 2(1 g)
4 6 + 4 = 2(1 0)
!44
Euler Poincaré Formula
V E + F = 2(1 g)
16 32 + 16 = 2(1 1)
!45
Average Valence of Closed Triangle Mesh
Theorem: Average vertex degree in a closed manifold
triangle mesh is ~6
Proof: 3F = 2E by counting edges of faces!
!
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) ~6 for large V
!46
Euler Consequences
Triangle mesh statistics!
• F ⇡ 2V
• E ⇡ 3V
• Average valence = 6
Quad meshe statistics!
• F ⇡V
• E ⇡ 2V
• Average valence = 4
!47
Euler Characteristic
Sphere Torus Moebius Strip Klein Bottle
=2 =0 =0 =0
!48
How many pentagons?
!49
How many pentagons?
Any closed surface of genus 0 consisting only of
hexagons and pentagons and where every vertex
has valence 3 must have exactly 12 pentagons
!50
Two-Manifold Surfaces
Local neighborhoods are disk-shaped!
!
f (D✏ [u, v]) = D [f (u, v)]
!
Guarantees meaningful neighbor enumeration!
• required by most algorithms
!
Non-manifold Examples:
!51
Outline
• Parametric Approximations
• Polygonal Meshes
• Data Structures
!52
Mesh Data Structures
• 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
!53
Data Structures
What should be stored?!
• Geometry: 3D vertex coordinates
• Connectivity: Vertex adjacency
• Attributes:
• normals, color, texture coordinates, etc.
• Per Vertex, per face, per edge
!54
Data Structures
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
!55
Data Structures
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
!56
Data Structures
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
!57
Face Set (STL)
Face:!
Triangles
• 3 vertex positions
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
9*4 = 36 B/f (single precision)!
72 B/v (Euler Poincaré)
!
No explicit connectivity
!58
Shared Vertex (OBJ,OFF)
Indexed Face List:!
Vertices Triangles
• Vertex: position
x1 y1 z1 i11 i12 i13
• Face: Vertex Indices
... ...
xV yV zV ...
...
...
iF1 iF2 iF3
12 B/v + 12 B/f = 36B/v
!
No explicit adjacency info
!59
Face-Based Connectivity
Vertex:!
• position
• 1 face
!
Face:!
• 3 vertices
• 3 face neighbors
64 B/v!
!
No edges: Special case
handling for arbitrary
polygons
!60
Edges always have the same !
topological structure
Efficient handling of polygons with!
variable valence
!61
(Winged) Edge-Based Connectivity
Vertex:!
• position
• 1 edge
!
Edge:!
• 2 vertices
• 2 faces
• 4 edges
! 120 B/v
!
Face:! Edges have no orientation:
• 1 edges special case handling for
neighbors
!62
Halfedge-Based Connectivity
Vertex:!
• position
• 1 halfedge
!
Edge:!
• 1 vertex
• 1 face
• 1, 2, or 3 halfedges
96 to 144 B/v!
! !
Edges have orientation: No-
Face:!
runtime overhead due to
• 1 halfedge arbitrary faces
!63
Arbitrary Faces during Modeling
!64
One-Ring Traversal
1. Start at vertex
!65
One-Ring Traversal
1. Start at vertex
2. Outgoing halfedge
!66
One-Ring Traversal
1. Start at vertex
2. Outgoing halfedge
3. Opposite halfedge
!67
One-Ring Traversal
1. Start at vertex
2. Outgoing halfedge
3. Opposite halfedge
4. Next halfedge
!68
One-Ring Traversal
1. Start at vertex
2. Outgoing halfedge
3. Opposite halfedge
4. Next halfedge
5. Opposite
!69
One-Ring Traversal
1. Start at vertex
2. Outgoing halfedge
3. Opposite halfedge
4. Next halfedge
5. Opposite
6. Next
7. …
!70
Halfedge datastructure Libraries
CGAL!
• www.cgal.org
• Computational Geometry
• Free for non-commercial use
!
OpenMesh!
• www.openmesh.org
• Mesh processing
• Free, LGPL license
!71
Why Openmesh?
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
!72
Literature
• 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
!73
TODO
Learn the terms
and notations
!74
Next Time
• Explicit & Implicit Surfaces
• Exercise 1: Getting Started with Mesh Processing
!75
http://cs599.hao-li.com
Thanks!
!76