15
1 Meshes, data structures, simplification CS 175 Meshes 82K vertices 164K triangles Simple file format? Data structures? 4 vertices 4 triangles

Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

Embed Size (px)

Citation preview

Page 1: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

1

Meshes,data structures,simplification

CS 175

Meshes

82K vertices164K triangles

Simple file format?

Data structures?

4 vertices4 triangles

Page 2: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

2

Wavefront file formatn Tetrahedron

# OBJ file format with ext .objv 1.0 0.0 0.0v 0.0 1.0 0.0v 0.0 0.0 1.0v 0.0 0.0 0.0f 2 4 3f 4 2 1f 3 1 2f 1 3 4

v x y z vertex f v1 v2 v3 face# comment

Objectsn Faces: polygons, triangles

n normal, area

n Verticesn coordinates, normal

n Edgesn creases, dihedral angles

n Boundariesn Euler formula:

n genus = 1 - (V-E+F+B)/2 n 4 - 5 + 2 + 1 = 2; 1 - 2/2 = 0

Page 3: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

3

A factn usually for big meshes:

n F ≈ 2 Vn E ≈ 3 Vn why?

n usen average valence is sixn go through verts

n count adjacent facesn 6 V ≈ 3 F

Data structuresn Operations

n find normaln flat

n three verts of a face

n smoothn average normals: one-ring

» or

n use formula from subdivision

n given a face find verticesn given a vertex find faces

Page 4: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

4

OpenGLn Flat shaded triangles

glBegin(GL_TRIANGLES);for(....) {

....glNormal3fv(n);glVertex3fv(v1); glVertex3fv(v2); glVertex3fv(v3);

}glEnd();

OpenGLn Smooth shaded triangles

....glNormal3fv(n1);glVertex3fv(v1);glNormal3fv(n2); glVertex3fv(v2); glNormal3fv(n3);glVertex3fv(v3);....

Page 5: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

5

Operationsn naive procedure for smooth shaded:

n iterate through vertsn for every vertex compute normal

n need one ring of neighbors

n iterate through facesn for every face render a triangle with

normalsn face -> vertices

Face based meshn Vertex container

n vertex: 3 floats, 1 pointern coordinatesn pointer to adjacent face

n Face containern face: 6 pointers + ...

n pointers to neighbors, verticesn permutations

n no edges explicitlyn (v1, v2) or (f, side)

Page 6: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

6

“permutations”n Useful to store orientation of the

neighboring facen a = [ A, C, B ]n b = [ C, D, B ]n a’s neighbors:

n (a, (0,1)) -> ..n (a, (1,2)) -> (b, (0,2))n (a, (2,0)) -> ..

a

b

A B

C D

02

10 1

2

Navigation: efsn Edge-face (ef)n Operations

n dest, org, facen sym, enext, fnext

n fnext(fnext(ef))==ef: fnext2 ==idn enext3==id, sym2==idn org(fnext(ef))==org(ef)n sym(org(ef))==dest(ef)

fnext(ef)

dest(ef)

ef

org(ef)

enext(ef)

Page 7: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

7

Additional operationsn Bisection

n adds a vertexn bisect(ef, alpha)

n Edge-collapsen removes a vertex

n Edge-flipn beware of valence three

n these are useful. why?

Alternative: winged edgen Edge knows

n four edgesn two vertsn two faces

n Face knows n one edge

n Vertex knowsn one edge

Page 8: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

8

Manifold conditionn Two kinds of vertices allowed

n inside vertexn full umbrella neighborhood

n boundary vertexn half umbrella neighborhood

n Prohibited configurations

Normalsn At a vertexn Tangent vectors

v0 v4

v3

v2

v1

)2cos(0

Nipt

N

ii

u π∑=

=

)2sin(0

Nipt

N

ii

v π∑=

=

vu ttn ×= tu

tv

n

Page 9: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

9

Normals IIn Indeed for valence four

1

-1

00

0

0

1-1

Mean curvaturen Surface locally is like

n mean curvature is

n another way:

n Desbrun et al. ‘99:

221 κκ

κ+

=

22

21 yxz κκ +=

AA∇=⋅nκ

nppj ⋅−+−= ∑−

=

))(cot(cot41 1

0j

N

jjA

βακ

v0 v4

v3v2

v1

p

pj

pj+1

pj-1αj

βj

Page 10: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

10

n Why do we need curvature?

Programming Assignment 1n Implement a mesh class

n Read/write .obj filen Show it in the viewer

n compute normals n flat and smooth shading

n compute curvatures

n OpenGL code providedn Keep in mind:

n p.a. #2 is mesh simplificationn p.a. #3 is subdivision

Page 11: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

11

Mesh simplification

num of verts: 81457num of faces: 162910

60K verts 17K verts 400 verts

Clearly very importantn Laser scan is too finen Large planar areasn Rendering performancen Base for multires algorithms

n parameterizationn filteringn editingn progressive compression/transmission

Page 12: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

12

Edge contractionn Hoppe and others ...

n need order in which to remove pointsn suggestions?

Polyline simplificationn How to simplify?n What is our goal?n pause.

Page 13: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

13

Size vs error

number of vertices

error

Performancen Rate distortion curve

n compare different methods

n order defines performance

number of verticesarchive size -- rate

error

Page 14: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

14

Choicesn Error from original

n usually too slown Local criteria

n fastern many small errors add upn each face responsible for region of the

original geometryn Need to accumulate error

n quadrics by Garland & Heckbert ‘97n programming assignment 2

Errorn Distance from a plane

n <n,p> = d

Page 15: Meshes, data structures, simplificationusers.cms.caltech.edu/~cs175/cs175-01/notes/lecture-4-4.pdf · Meshes, data structures, simplification CS 175 Meshes 82K vertices ... n need

15

Error IIn Distance from several planes

n maxn mean

n advantages