66
Geometric Modeling Bing-Yu Chen National Taiwan University

Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

  • Upload
    vudang

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Geometric Modeling

Bing-Yu ChenNational Taiwan University

Page 2: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Solid Modeling

Regularized Boolean Set Operations

Boundary Representations

Spatial-Partitioning Representations

Marching Cubes

Implicit Surfaces

Constructive Solid Geometry

Page 3: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

What is Solid ?

extra face

Page 4: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Ordinary Boolean Set Operations

the result may not be a solid model !

A

B

BA BA BA AB

Page 5: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Regularized Boolean Set Operations

boundary / interior points points whose distance from the

object and the object’s complement is zero / other points

closed set a set contains all its boundary

points

open set a set contains none of its boundary

points

Page 6: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Regularized Boolean Set Operations

closure the union of a set with the set of

its boundary points

is a closed set

boundary the set of closed set’s boundary

points

interior the complement of the boundary

with respect to the object

Page 7: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Regularized Boolean Set Operations

regularization

the closure of a set’s interior points

regular set

a set is equal to its own regularization

regularized Boolean set operator

A op* B = closure (interior (A op B))

only produce the regular set when applied to regular sets

Page 8: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Ordinary vs. RegularizedBoolean Set Operations

dangling face

Page 9: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Ordinary Boolean Operations onSubsets of Two Objects

ii BA BAi ABi

AB

BA and ib BA

ib AB BAb ABb sameBA bb diffBA bb

Page 10: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Regularized Boolean Set Operations

set

X X

X X

X

X

X X

X X

X

X X

X

ii BA

BAi

ABi

ib BA

ib AB

BAb

ABb

sameBA bb

diffBA bb

BA BA BA

Page 11: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Boundary Representations = b-reps

describe an object in terms of its surface boundaries

vertices / edges / faces

some b-reps are restricted to planar, polygonal boundaries, and may require faces to be convex polygons or triangles

some systems support only solids whose boundaries are 2-manifolds

Page 12: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Spatial-Partitioning Representations

Cell Decomposition

Spatial-Occupancy Enumeration

Octrees

Binary Space-Partitioning Trees

Page 13: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Cell Decomposition

Page 14: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Spatial-Occupancy Enumeration

Page 15: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Quadtree (Octrees)

Page 16: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Space Subdivision Approaches

Uniform grid K-d tree

Page 17: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Space Subdivision Approaches

Quadtree (2D)Octree (3D)

BSP tree

Page 18: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Uniform Grid

Page 19: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Preprocess scene

1. Find bounding box

Uniform Grid

Page 20: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Preprocess scene

1. Find bounding box

2. Determine grid resolution

Uniform Grid

Page 21: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Uniform Grid

Preprocess scene

1. Find bounding box

2. Determine grid resolution

3. Place object in cell if its bounding box overlaps the cell

Page 22: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Uniform Grid

Preprocess scene

1. Find bounding box

2. Determine grid resolution

3. Place object in cell if its bounding box overlaps the cell

4. Check that object overlaps cell (expensive!)

Page 23: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

A

A

Leaf nodes correspond to unique regions in space

K-d Tree

Page 24: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Leaf nodes correspond to unique regions in space

A

A

B

K-d Tree

Page 25: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Leaf nodes correspond to unique regions in space

A

B

A

B

K-d Tree

Page 26: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

A

B

A

B

C

K-d Tree

Page 27: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

A

B

C A

B

C

K-d Tree

Page 28: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

A

B

C A

B

C

D

K-d Tree

Page 29: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

A

B

C

D

A

B

C

D

K-d Tree

Page 30: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Quadtree Data Structure

Quadrant Numbering

Page 31: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Octree Enumeration

x

y

z

Page 32: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Boolean Set Operationson Quadtrees

Page 33: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Binary Space-Partitioning Trees

An improved painter’s algorithm

Key observation:

T1

T2

Ax+By+Cz+D=0

f(p): n(p-a)=0

f(p)>0

f(p)<0

T3

T4

T5

Page 34: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Binary Space-Partitioning Trees

T1

T2

T2 T3

T1+-

T3

Page 35: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Binary Space-Partitioning Trees

T1

T2

T3

T3

T1+-

T2+-

Page 36: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Splitting trianglesa

b

c

A

B

a

b

c

A

B

Page 37: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

BSP Tree Construction

BSPtree makeBSP(L: list of polygons) {if (L is empty) {

return the empty tree;} Choose a polygon P from L to serve as root;Split all polygons in L according to Preturn new TreeNode (

P,makeBSP(polygons on negative side of P),makeBSP(polygons on positive side of P))

}

Splitting polygons is expensive! It helps to choose P wisely at each step.

Example: choose five candidates, keep the one that splits the fewest polygons.

Page 38: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

BSP Tree Display

void showBSP(v: Viewer, T: BSPtree) {

if (T is empty) return;

P = root of T;

if (viewer is in front of P) {

showBSP(back subtree of T);

draw P;

showBSP(front subtree of T);

} else {

showBSP(front subtree of T);

draw P;

showBSP(back subtree of T);

}

} 2D BSP demo

Page 39: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Binary Space-Partitioning Trees

P1

P2A

B

C

D

1

2

3

P1

P2 P2

A BCD

3,1,2 3,2,1 1,2,3 2,1,3

front

front front

back

backback

extremely efficient for static objects

Page 40: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Binary Space-Partitioning Trees

Same BSP tree can be used for any eye position, constructed only once if the scene if static.

It does not matter whether the tree is balanced. However, splitting triangles is expensive and try to avoid it by picking up different partition planes.

Page 41: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

3

4

1

2

56

7

9

8

11

10

BSP Tree

Page 42: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

3

4

1

2

56

7

1

inside

ones

outside

ones9

8

11

10

BSP Tree

Page 43: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

3

4

1

2

56

7

1

2

3

4

5

6

7

8

9

10

11

9

8

11

10

BSP Tree

Page 44: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

3

4

1

2

9

8

11

10

56

7

9b

9a

1

5

6

7

9a

10

11a11a

11b8

9b

11b

BSP Tree

Page 45: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

3

4

1

2

9

8

11

10

56

7

9b

11a

2

3

4

1

5

6

7

9a

10

11a

8

9b

11b

9a11b

BSP Tree

Page 46: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

3

4

1

2

9

8

11

10

56

7

9b

point

11a

2

3

4

1

5

6

7

9a

10

11a

8

9b

11b

9a11b

BSP Tree

Page 47: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

3

4

1

2

9

8

11

10

56

7

9b

point

11a

2

3

4

1

5

6

7

9a

10

11a

8

9b

11b

9a11b

BSP Tree Traversal

Page 48: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

1

2

9

8

11

10

56

7

9b

point

11a

2

3

4

1

5

6

7

9a

10

11a

8

9b

11b

9a11b

3

4

BSP Tree Traversal

Page 49: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

From Volume to Mesh:Marching Cubes

First 2D, Marching Squares

William E. Lorensen and Harvey E. Cline. Marching cubes: a high resolution 3D surface construction algorithm. ACM Computer Graphics (SIGGRAPH 1987 Conference Proceedings), Vol. 21, No. 4, p.163 - p.169, 1987.

Page 50: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Marching Cubes Table

Using binary pattern of eight vertices

Totally 256 cases in 15 configurations

Page 51: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

From Volume to Mesh:Marching Cubes

Page 52: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Steps of Marching Cubes

Page 53: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Adaptive Resolution

[Wilhelms and Gelder 1992]

[Shu et al. 1995], etc.

Page 54: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Adaptive Resolution

Page 55: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Crack Patching

Page 56: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Consistent Topology

Ambiguity problems

[Nielson and Hamann 1991]

[Natarajan 1994]

[Chernyaev 1995], etc.

Page 57: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Sharp Features

[Kobbelt et al. 2001], EMC (Extended Marching Cubes).

[Ju et al. 2002], DC (Dual Contouring)

Page 58: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Implicit Surfaces

Real function

Classifies points in space

Image synthesis (sometimes)

inside

outside

on the surface

( , , )f x y z

0f

0f

0f 0f

0f

0f

Page 59: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Why use Implicits?

vs. polygons

smoother

compact, fewer higher-level primitives

harder to display in real time

vs. parametric surfaces

easier to blend

no topology problems

lower degree

harder to parameterize

easier to ray trace

Page 60: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Quadric Surfaces

implicit surface equation

an alternative representation

with

0222222),,( 222 kjzhygxfxzeyzdxyczbyaxzyxf

0T PQP

kjhg

jcef

hebd

gfda

Q

1

z

y

x

P

Page 61: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Quadric Surfaces

Ellipsoid (Sphere):

Cylinder:

Hyperboloid (Cone):

Paraboloid:

2 2 2( , , ) 1 0f x y z ax by cz

2 2 2( , , ) 0f x y z ax by cz k

2 2( , , ) 2 0f x y z ax by jz

2 2( , , ) 1 0f x y z ax by

Page 62: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Torus

Product of two implicit circles2 2 2

2 2 2

2 2 2 2 2 2

2 2 2 2 2 2 2

( ) 0

( ) 0

(( ) )(( ) ) 0

( ) 4 ( )

F x R z r

G x R z r

F G x R z r x R z r

x z r R R z r

R

r

Page 63: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Constructive Solid Geometry (CSG)

Page 64: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Constructive Solid Geometry (CSG)

B

A A

B

BA BA

Page 65: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

CSG for Implicit Surfaces

Assume inside

CSG ops by min/max ops

Union:

Intersection:

Complement:

Subtraction:0f 0g

0g

0f

0f

max( , )f g

max( , )f g

min( , )f g

f

Page 66: Bing-Yu Chen National Taiwan University - graphics…robin/courses/gm13/ppt/gm... · Regularized Boolean Set Operations closure the union of a set with the set of its boundary points

Blobs

Sum of Gaussians

B – blobbiness (positive)

R – radius of blob at rest

r – radius function

2 2 2 2

2 2

( , , )

( ) 1 exp( ( / ) )

i

i i i i

r x y z x y z

f x B R r B