bing-yu chen national taiwan university · regularized boolean set operations closure the union of...

66
Geometric Modeling Bing-Yu Chen National Taiwan University

Upload: phungnhan

Post on 08-Sep-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Geometric Modeling

Bing-Yu ChenNational Taiwan University

Solid Modeling

Regularized Boolean Set Operations

Boundary Representations

Spatial-Partitioning Representations

Marching Cubes

Implicit Surfaces

Constructive Solid Geometry

What is Solid ?

extra face

Ordinary Boolean Set Operations

the result may not be a solid model !

A

B

BA BA BA AB

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

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

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

Ordinary vs. RegularizedBoolean Set Operations

dangling face

Ordinary Boolean Operations onSubsets of Two Objects

ii BA BAi ABi

AB

BA and ib BA

ib AB BAb ABb sameBA bb diffBA bb

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

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

Spatial-Partitioning Representations

Cell Decomposition

Spatial-Occupancy Enumeration

Octrees

Binary Space-Partitioning Trees

Cell Decomposition

Spatial-Occupancy Enumeration

Quadtree (Octrees)

Space Subdivision Approaches

Uniform grid K-d tree

Space Subdivision Approaches

Quadtree (2D)Octree (3D)

BSP tree

Uniform Grid

Preprocess scene

1. Find bounding box

Uniform Grid

Preprocess scene

1. Find bounding box

2. Determine grid resolution

Uniform Grid

Uniform Grid

Preprocess scene

1. Find bounding box

2. Determine grid resolution

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

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!)

A

A

Leaf nodes correspond to unique regions in space

K-d Tree

Leaf nodes correspond to unique regions in space

A

A

B

K-d Tree

Leaf nodes correspond to unique regions in space

A

B

A

B

K-d Tree

A

B

A

B

C

K-d Tree

A

B

C A

B

C

K-d Tree

A

B

C A

B

C

D

K-d Tree

A

B

C

D

A

B

C

D

K-d Tree

Quadtree Data Structure

Quadrant Numbering

Octree Enumeration

x

y

z

Boolean Set Operationson Quadtrees

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

Binary Space-Partitioning Trees

T1

T2

T2 T3

T1+-

T3

Binary Space-Partitioning Trees

T1

T2

T3

T3

T1+-

T2+-

Splitting trianglesa

b

c

A

B

a

b

c

A

B

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.

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

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

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.

3

4

1

2

56

7

9

8

11

10

BSP Tree

3

4

1

2

56

7

1

inside

ones

outside

ones9

8

11

10

BSP Tree

3

4

1

2

56

7

1

2

3

4

5

6

7

8

9

10

11

9

8

11

10

BSP Tree

3

4

1

2

9

8

11

10

56

7

9b

9a

1

5

6

7

9a

10

11a11a

11b8

9b

11b

BSP Tree

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

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

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

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

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.

Marching Cubes Table

Using binary pattern of eight vertices

Totally 256 cases in 15 configurations

From Volume to Mesh:Marching Cubes

Steps of Marching Cubes

Adaptive Resolution

[Wilhelms and Gelder 1992]

[Shu et al. 1995], etc.

Adaptive Resolution

Crack Patching

Consistent Topology

Ambiguity problems

[Nielson and Hamann 1991]

[Natarajan 1994]

[Chernyaev 1995], etc.

Sharp Features

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

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

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

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

Quadric Surfaces

implicit surface equation

an alternative representation

with

0222222),,( 222 kjzhygxfxzeyzdxyczbyaxzyxf

0T PQP

kjhg

jcef

hebd

gfda

Q

1

z

y

x

P

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

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

Constructive Solid Geometry (CSG)

Constructive Solid Geometry (CSG)

B

A A

B

BA BA

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

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