東工大PPTフォーム(英語)上

Download Report

Transcript 東工大PPTフォーム(英語)上

Geometric Modeling
using Polygonal Meshes
Lecture 2: Mesh data structures
Hamid Laga
[email protected]
http://www.img.cs.titech.ac.jp/~hamid/
Office: South 6- 401B-C
Global Edge Institute
Tokyo Institute of Technology
Overview
– Introduction and applications
– Geometry processing pipeline
– Surface representations
– Parametric surface representations
(Spline surfaces, subdivision surfaces, triangle meshes)
– Implicit surface representations
(Regular grids, adaptive data structures)
– Summary (conversion methods)
– Mesh data structures
– Considerations when choosing a mesh data structure
– List of faces, Adjacency matrix, Half Edge data structure.
– Mesh libraries
– Summary
2
Overview
– Introduction and applications
– Geometry processing pipeline
– Surface representations
– Parametric surface representations
(Spline surfaces, subdivision surfaces, triangle meshes)
– Implicit surface representations
(Regular grids, adaptive data structures)
– Summary (conversion methods)
– Mesh data structures
– Considerations when choosing a mesh data structure
– List of faces, Adjacency matrix, Half Edge data structure, Directed Edges.
– Mesh libraries
– Summary
3
Why triangular meshes
• The most popular representation in graphics
– Can represent any arbitrary shape
– It’s the input of the graphics pipeline
V: Vertices (X, Y, Z)
F: Faces (V1, V2, V3)
Polygons (vertices + faces)
4
Meshes
• Formal definition
– Straight-line graph embedded in R3
Boundary
Singular edge
Node
Regular edges
5
Meshes
• Formal definition
– Straight-line graph embedded in R3
6
What can we do with a mesh ?
– Use of mesh data for:
– Rendering
– Geometric queries
• What are the vertices of face #3 ?
• Are vertices i and j adjacent ?
• Which faces are adjacent to face #7 ?
– Geometric operations
• Remove / add a vertex / face.
7
Considerations
– Topological requirements
– Which kind of meshes need to be represented ?
– Do we need boundaries or do we assume a closed
mesh ?
– Complex edges and singular vertices OR just
manifold mesh ?
– Triangle meshes OR arbitrary polygon meshes ?
– Are the meshes regular, semi-regular, or irregular?
8
Considerations
– Algorithmic requirements
– Which kind of algorithms will be operating on the
mesh data structure ?
– Do we want:
• Simply rendering ?
• Modify only the geometry of the mesh OR modify also
the connectivity / topology ?
• Associate additional data to the vertices, faces, edges ?
• Have constant-time access to the local neighborhoods
of vertices, edges, faces ?
• Can we assume the mesh to be globally orientable ?
9
How good is a mesh data structure ?
– Time to reconstruct / preprocess
– Time to answer a query
– Time to perform an operation (update the
data structure)
– Space complexity
– Redundancy
10
The simplest data structure
– List of faces:
– A set of vertices and faces:
• List of vertices (coordinates)
• List of faces
V: Vertices (X, Y, Z)
F: Faces (V1, V2, V3)
Polygons (vertices + faces)
11
List of faces
– Queries:
– What are the vertices of face #3 ?
• Answered in O(1)
– Are vertices i and j adjacent ?
• A pass over all faces is necessary  NOT GOOD
12
List of faces example
13
List of faces – pros and cons
– Pros:
– Convenient and efficient
• Memory wise
• Cons
– Too simple
• Not enough information on relations between vertices
and faces
14
Mesh data structures
– Adjacency matrix
– View a mesh as a connected graph
– Given n vertices build n*n matrix of adjacency
information
• Entry (i,j) is TRUE value if vertices i and j are adjacent
– Geometric information:
• List of vertex coordinates
– Add faces
• list of triplets of vertex indices (v1,v2,v3)
15
Adjacency matrix example
16
Adjacency matrix – queries
• What are the vertices of face #3?
– O(1)
• checking third triplet of faces
• Are vertices i and j adjacent?
– O(1)
• checking adjacency matrix at location (i,j).
• Which faces are adjacent to vertex j?
– O(n)
• Full pass on all faces is necessary
17
Adjacency matrix– pros and cons
– Pros:
– Information on vertices adjacency
– Stores non-manifold meshes
• Cons
– Connects faces to their vertices, BUT NO
connection between vertex and its face
18
Mesh data structures
– DCEL: Doubly Connected Edge List
– Record for each face, edge and vertex:
• Geometric information
• Topological information
• Attribute information
• Aka Half-Edge Structure
19
Half-Edge structure
(Opposite)
20
Half-Edge structure - example
Face table
Vertex table
21
Half-Edge structure - example
Face table
Vertex table
Halfe-Edge table
22
Half-Edge structure
– Operations supported
– Walk around the boundary of a given face
– Visit all edges incident to a vertex v
• Queries
– Most queries are O(1)
– Example
– Enumerate all vertices that
are adjacent to a given vertex
–  this is called the one-ring of a vertex
23
Half-Edge structure -Example
– Example
– Enumerate all vertices that
are adjacent to a given vertex v
– HalfEdge h = outgoing_halfedge(v)
– HalfEdge hstop = h;
– Do
• Vertex w = h->opposite()->origine
• // DO SIMETHING WITH VERTEX w
• h = h->opposite()->next_halfEgde();
– While (h != hstop)
24
Half-Edge structure
– Operations supported
– Walk around the boundary of a given face
– Visit all edges incident to a vertex v
• Queries
– Most queries are O(1)
– Pros
– All queries in O(1)
– All operations in O(1)
• Cons
– Represent only manifold meshes
25
Other mesh data structures
– Directed Edges
– Corner tables
26
Example: mesh smoothing
Noisy 3D model
27
Example: mesh smoothing
Noisy 3D model
28
After smoothing
Example: mesh smoothing
29
Example: mesh smoothing
• Mesh smoothing
– Moving mesh vertices on surface to reduce the
curvature variation and remove the noise.
– Similar to high frequency elimination in signal
processing
30
Basic mesh smoothing algorithm
• Laplacian smoothing
– Equivalent to box filter in signal processing
1
vi 
(v j  vi )

| N (vi ) | jN ( vi )
vi
vi  vi  vi
• N(vi) is the neighboring vertices
of vertex vi
One-ring
Neighborhood of vi
– Apply it to all vertices of the mesh
– Typically, repeat the operation many times.
31
Laplacian smoothing algorithm
• Algorithm
vi 
1
 (v j  vi )
| N (vi ) | jN ( vi )
vi  vi  vi
32
Complexity of the Laplacian smoothing
• List of faces:
O(1)
33
Complexity of the Laplacian smoothing
• List of faces:
O(1)
O(numberOfFaces)
34
Mesh data structures revisited
– We want to perform all mesh queries in O(1)
– DCEL: Doubly Connected Edge List
– Record for each face, edge and vertex:
• Geometric information
– Coordinates of each vertex
• Topological information
– Connectivity
• Attribute information
– Color, texture, etc
• Aka Half-Edge Structure
35
Half-Edge structure
• The mesh is defined as a directed graph
– Connections between vertices defined by directed edges
called Half-Edges:
• V2 V3: e3,1
V3V2: e3,2
– Each face has 3 oriented edges (counter-clockwise)
• Face f1 has e3,1 e1,1 and e2,1
36
Half-Edge structure
– Half-edge record
– Pointer to its origin (Vertex)
• origin(e)
– Pointer to its opposite half-edge
• opposite(e)
– Pointer to the face it bounds,
• IncidentFace(e)
• (face lies to the left of e when traversed from origin to destination)
– Next edge on the boundary of IncidentFace(e)
• Next (e)
– We can add also prev(e) = next(next(e))
– Vertex record
– Coordinates
– Incident half-edge:
• Pointer to one half-edge that has this vertex
as its origin
– Face record
– Pointer to one half-edge on its boundary.
37
(Opposite)
Half-Edge structure
(Opposite)
38
Half-Edge structure
(Opposite)
39
Half-Edge structure - example
Vertex table (lisOfVertices)
40
Face table (listOfFaces)
Half-Edge structure - example
Face table
Vertex table
Halfe-Edge table (listOfHalfEdges)
41
Half-Edge structure -Example
– Laplacian smoothing
1
vi 
(v j  vi )

| N (vi ) | jN ( vi )
vj
vi
vi  vi  vi
One-ring Neighborhood of vi
42
Half-Edge structure -Example
O(1)
One-ring Neighborhood of vi
43
Half-Edge structure
– Operations supported
– Walk around the boundary of a given face
– Visit all edges incident to a vertex v
• Queries
– Most queries are O(1)
– Example
– Enumerate all vertices that
are adjacent to a given vertex
–  this is called the one-ring of a vertex
44
Half-Edge structure
– Operations supported
– Walk around the boundary of a given face
– Visit all edges incident to a vertex v
• Queries
– Most queries are O(1)
– Pros
– All queries in O(1)
– All operations in O(1)
• Cons
– Represent only manifold meshes
– Cannot be used for polygon soup models !!
– The creation of the data structure is time consuming (of order
O(N2))
• But this is done only once
45
Mesh libraries
– CGAL:
–
–
–
–
Computational Geometry Algorithms Library
Generic C++ Library for geometric computing
Linux, Windows
www.cgal.org
• OpenMesh
– Efficient Half-Edge structures for polygonal meshes
– www.openmesh.org
• MeshMaker
– Code: http://www.cs.ubc.ca/~sheffa/dgp/software/MeshMaker5.2.zip
• Graphite:
– More powerful than MeshMaker,
– more efficient but Linux only
– http://alice.loria.fr/software/graphite/
46
Assignment 1
• Parametric and implicit representation
– Sphere
– Cylinder
47
Assignment 2 (due on 2009/6/25)
• Complexity of mesh data structures
– What is the complexity (big O) of the following
queries:
• Collapse two adjacent vertices i and j (called edge collapse)
• Split a vertex i into two vertices (vertex split)
• in both cases I shouldn’t leave holes on the surface
– when using
• The list of faces
• The Half-Edge data structure
• Algorithm
– Write the two algorithms (edge collapse, vertex split)
when using Half-edge data structure
48
Assignment 2
– Edge collapse (ecol) and Vertex split (vsplit)
49
How to submit a report
– Rule 1:
– Don’t submit hand written report
• It’s very hard for me to read it !!
• Rule 2:
– There are many solutions (algorithms) for solving the same
problem
•  the solution you propose maybe different from the one I know.
•  if you don’t explain your solution it will be very hard for me to
understand your algorithm
•  Explain your solution before giving the algorithm
•  Add comments inside your algorithm.
• Submit a printed copy to me on June 25th before the
class.
50
Summary
– Surface representations
– Parametric, implicit
• Triangular mesh representation
– The most flexible
– Can be used for rendering as well as for geometry
processing
• Mesh data structures
– Should be chosen according to the type of
processing
51
Online resources
– This course website:
• http://www.img.cs.titech.ac.jp/~hamid/courses/cg2009
/cg_2009.php
• Acknowledgment
– Materials of this course are based on:
• Siggraph 2007 and Eurographics 2006 courses on
Geometry Processing using polygonal meshes:
– http://www.agg.ethz.ch/publications/course_notes
• Alla Sheffer’s course on Digital Geometry Processing
– http://www.cs.ubc.ca/~sheffa/dgp/
52