610 likes | 924 Views
Geometric Modeling using Polygonal Meshes Lecture 2: Mesh data structures. Hamid Laga hamid@img.cs.titech.ac.jp http://www.img.cs.titech.ac.jp/~hamid/. Office: South 6- 401B-C Global Edge Institute Tokyo Institute of Technology. Overview. Introduction and applications
E N D
Geometric Modeling using Polygonal MeshesLecture 2: Mesh data structures Hamid Laga hamid@img.cs.titech.ac.jp 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
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
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)
Meshes • Formal definition • Straight-line graph embedded in R3 Boundary Singular edge Node Regular edges
Meshes • Formal definition • Straight-line graph embedded in R3
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.
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?
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 ?
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
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)
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
List of faces – pros and cons • Pros: • Convenient and efficient • Memory wise • Cons • Too simple • Not enough information on relations between vertices and faces
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)
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
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
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
Half-Edge structure (Opposite)
Half-Edge structure - example Face table Vertex table
Half-Edge structure - example Face table Vertex table Halfe-Edge table
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
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)
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
Other mesh data structures • Directed Edges • Corner tables
Example: mesh smoothing Noisy 3D model
Example: mesh smoothing Noisy 3D model After smoothing
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
Basic mesh smoothing algorithm • Laplacian smoothing • Equivalent to box filter in signal processing • N(vi) is the neighboring vertices of vertex vi • Apply it to all vertices of the mesh • Typically, repeat the operation many times. vi One-ring Neighborhood of vi
Laplacian smoothing algorithm • Algorithm
Complexity of the Laplacian smoothing • List of faces: O(1)
Complexity of the Laplacian smoothing • List of faces: O(1) O(numberOfFaces)
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
Half-Edge structure • The mesh is defined as a directed graph • Connections between vertices defined by directed edges called Half-Edges: • V2V3: e3,1 V3V2: e3,2 • Each face has 3 oriented edges (counter-clockwise) • Face f1 has e3,1 e1,1 and e2,1
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. (Opposite)
Half-Edge structure (Opposite)
Half-Edge structure (Opposite)
Half-Edge structure - example Vertex table (lisOfVertices) Face table (listOfFaces)
Half-Edge structure - example Face table Vertex table Halfe-Edge table (listOfHalfEdges)
Half-Edge structure -Example • Laplacian smoothing vj vi One-ring Neighborhood of vi
Half-Edge structure -Example O(1) One-ring Neighborhood of vi
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
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
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/
Assignment 1 • Parametric and implicit representation • Sphere • Cylinder
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
Assignment 2 • Edge collapse (ecol) and Vertex split (vsplit)
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.