1 mesh data structures - technion
TRANSCRIPT
Digital Geometry Processing, Technion - Spring 2008
1
Mesh Data Structures
Digital Geometry Processing, Technion - Spring 2008
2
Geometry processingMesh data
Data structure selection depends on• Mesh type• Algorithm requirements
Geometry Connectivity
Digital Geometry Processing, Technion - Spring 2008
3
Mesh gallery
Single component,closed, triangular, orientable manifold
Multiple components
With boundaries
Not only triangles
Not orientable
Non manifold
Digital Geometry Processing, Technion - Spring 2008
4
In this courseOnly orientable, triangular, manifold meshes
Single component,closed, triangular, orientable manifold
Multiple components
With boundaries
Not only triangles
Not orientable
Non manifold
Digital Geometry Processing, Technion - Spring 2008
5
Algorithms’ requirements
Data structure should be efficient for• Rendering
• Geometry queriesWhat are the vertices of face #3?Are vertices i and j adjacent?Which faces are adjacent to vertex #7?
• Geometry operationsRemove/add a vertex/faceVertex split, edge collapse
Digital Geometry Processing, Technion - Spring 2008
6
Storing mesh data
How “good” is a data structure?
• Time to construct - preprocessing
• Time to answer a query
• Time to update
• Space complexity
• Redundancy
Digital Geometry Processing, Technion - Spring 2008
7
List of facesList of vertices - 3D coordinates
List of faces - triplets of vertex pointers (v1,v2,v3)
f1 f2
f3
f4v1
v2
v3
v4v5
v6
......
(x3, y3, z3)v3
(x2, y2, z2)v2
(x1, y1, z1)v1
coordinatesvertex
......
(v2, v4, v3)f2
(v1, v2, v3)f1
vertices (ccw)face
Digital Geometry Processing, Technion - Spring 2008
8
List of faces - queries
What are the vertices of face #3?• O(1) - third triplet from face list
Are vertices i and j adjacent?• Requires a full pass over all faces
f1 f2
f3
f4v1
v2
v3
v4v5
v6
......
(x3, y3, z3)v3
(x2, y2, z2)v2
(x1, y1, z1)v1
coordinatesvertex
......
(v2, v4, v3)f2
(v1, v2, v3)f1
vertices (ccw)face
Digital Geometry Processing, Technion - Spring 2008
9
List of faces – pros and cons
Pros:• Simple• Low memory requirements• Can represent “polygon soups”
Cons:• O(|F|) for queries like
Vertices adjacencyFaces near vertex
Digital Geometry Processing, Technion - Spring 2008
10
Adjacency matrixList of vertices - 3D coordinatesList of faces - triplets of vertex pointers (v1,v2,v3)
Adjacency matrix A of size |V|*|V|• A(i,j) = 1 iff vi and vj are adjacent
f1 f2
f3f4v1
v2
v3
v4v5
v6
......
(x3, y3, z3)v3
(x2, y2, z2)v2
(x1, y1, z1)v1
coordinatesvertex
......
(v2, v4, v3)f2
(v1, v2, v3)f1
vertices (ccw)face
1
1
1
1
v4 v6v5v3v2v1
11v6
1v5
1111v4
111v3
11v2
11v1
Digital Geometry Processing, Technion - Spring 2008
11
Adjacency matrix - queries
What are the vertices of face #3?• O(1) – third triplet from face list
Are vertices i and j adjacent?• O(1): A(i,j) == 1?
Which faces are adjacent to vertex j?• Requires a full pass on all faces
......
(x3, y3, z3)v3
(x2, y2, z2)v2
(x1, y1, z1)v1
coordinatesvertex
......
(v2, v4, v3)f2
(v1, v2, v3)f1
vertices (ccw)face
1
1
1
1
v4 v6v5v3v2v1
11v6
1v5
1111v4
111v3
11v2
11v1
Digital Geometry Processing, Technion - Spring 2008
12
Adjacency matrix – pros and cons
Pros:• Information on vertices adjacency• Can represent non-manifold meshes
Cons:• No connection between a vertex and its
adjacent facesO(|F|) for faces near vertex query
Digital Geometry Processing, Technion - Spring 2008
13
DCEL (Doubly-Connected Edge List)
Record for each face, edge and vertex:
• Geometric information• Topological information• Attribute information
aka Half-Edge Structure
Digital Geometry Processing, Technion - Spring 2008
14
DCEL Vertex record:
CoordinatesPointer to an outgoing half-edge
Face record:Pointer to an adjacent half-edge
v
f
Digital Geometry Processing, Technion - Spring 2008
15
DCELHalf-edge record:
Pointer to origin• origin(e)
Pointer to twin half-edge• twin(e)
Pointer to adjacent face• IncidentFace(e)• face left of e from origin to
destination
Next and previous edge of IncidentFace(e) • next(e)• prev(e)
e
Digital Geometry Processing, Technion - Spring 2008
16
DCEL
etw
in(e)
origin(e)
IncFace(e)prev(e)
next(e)
Digital Geometry Processing, Technion - Spring 2008
17
DCEL (cont.)
Operations supported:• Walk around boundary of given face• Visit all edges incident to vertex v
Queries:• Most queries are O(1)
Digital Geometry Processing, Technion - Spring 2008
18
DCEL - example
...
e1,1
e5,1
e2,1
outgoing edge
......
(x3, y3, z3)v3
(x2, y2, z2)v2
(x1, y1, z1)v1
coordinatevertex
......
e5,1f2
e1,1f1
adjacent edgeface
...e4,1
e2,1
prev
...e5,1
e1,1
next
...e3,1
e3,2
twin
...f2
f1
Incident Face
......v3e3,2
v2e3,1
originHalf-edge
f1 f2v1
v2
v3
e1,1e4,1
e3,2
e5,1
e3,1e2,1
Digital Geometry Processing, Technion - Spring 2008
19
DCEL – a larger example
e7,2
e9,1
e7,1
e1,1
e5,1
e2,1
IncidentEdge
(x6,y6,z6)v6
(x5,y5,z5)v5
(x4,y4,z4)v4
(x3,y3,z3)v3
(x2,y2,z2)v2
(x1,y1,z1)v1
coordinatevertex
e8,1f4
e4,2f3
e5,1f2
e1,1f1
edgeface
f1 f2
f3
f4v1
v2
v3
v4
v5
v6
e1,1
e6,1
e4,1 e7,2 e9,1
e8,1
e3,2
e5,1
e7,1
e3,1e2,1
e4,2
Digital Geometry Processing, Technion - Spring 2008
20
DCEL – a larger example
f1 f2
f3
f4v1
v2
v3
v4
v5
v6
e1,1
e6,1
e4,1 e7,2 e9,1
e8,1
e3,2
e5,1
e7,1
e3,1e2,1
e4,2
e6,1
e5,1
e4,1
e2,1
prev
e7,1
e3,2
e5,1
e1,1
next
e4,1
e4,2
e3,1
e3,2
twin
f3
f2
f2
f1
IncidentFace
v3e4,2
v4e4,1
v3e3,2
v2e3,1
originHalf-edge
Digital Geometry Processing, Technion - Spring 2008
21
DCEL – pros and cons
Pros:• All queries in O(1) time• All operations are O(1) (usually)
Cons:• Represents only manifold meshes
Digital Geometry Processing, Technion - Spring 2008
22
Corner c contains:Triangle – c.tVertex – c.vNext corner in c.t (ccw) - c.nPrevious corner - c.p(== c.n.n)Corner opposite c - c.o• Edge E opposite c not incident
on c.v• Triangle T adjacent to c.t across E• c.o.v vertex of T that is not incident on E
Right corner - c.r - corner opposite c.n (== c.n.o).Left corner - c.l (== c.p.o == c.n.n.o)
Corner table
cc.l=c.p.oc.r=c.n.o
c.o
c.pc.n
c.v
c.n.v
c.o.v
c.p.v
c.l.vc.r.v
c.t
Edge E
Corner : Coupling of vertex with one of its incident triangles.
Digital Geometry Processing, Technion - Spring 2008
23
Corner table - example
c6NULLNULLc1c3f1v2c2
NULLNULLc6c3c2f1v1c1
c1c7NULLc6c5f2v3c4
NULLc6NULLc2c1f1v3c3
NULLc1c7c4c6f2v2c5
c7NULLc1c5c4f2v4c6
c.lc.rc.oc.pc.nc.tc.vcorner
f1 f2
f3
f4v1
v2
v3
v4
v5
v6
c1
c2c5
c3 c4
c6 c10
c12
c11
c9
c8
c7
Digital Geometry Processing, Technion - Spring 2008
24
Corner table – pros and cons
Pros:• All queries in O(1) time• All operations are O(1) (usually)
Cons:• Only triangular, manifold meshes• High redundancy (but not too high …)
Digital Geometry Processing, Technion - Spring 2008
25
Additional details
Corner table
For each vertex – a list of all its corners
Corners number j*3, j*3+1 and j*3+2 match face number j
Corner number = EdgeID of opposite edge
Digital Geometry Processing, Technion - Spring 2008
26
Examples of queries
What are the vertices of face #3?• Check c.v of corners 9, 10, 11
Are vertices i and j adjacent?• Scan all corners of vertex i, check if c.p.v or c.n.v are j
Which faces are adjacent to vertex j?• Check c.t of all corners of vertex j