data visualization (dsc 530/cis 568)

40
Data Visualization (DSC 530/CIS 568) Isosurfacing Dr. David Koop D. Koop, DSC 530, Spring 2019

Upload: others

Post on 12-Nov-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data Visualization (DSC 530/CIS 568)

Data Visualization (DSC 530/CIS 568)

Isosurfacing Dr. David Koop

D. Koop, DSC 530, Spring 2019

Page 2: Data Visualization (DSC 530/CIS 568)

Data Wrangling• Problem 1: Visualizations need data • Solution: The Web!

• Problem 2: Data has extra information I don't need • Solution: Filter it • Problem 3: Data is dirty • Solution: Clean it up

• Problem 4: Data isn't in the same place • Solution: Combine data from different sources • Problem 5: Data isn't structured correctly • Solution: Reorder, map, and nest it

�2D. Koop, DSC 530, Spring 2019

Page 3: Data Visualization (DSC 530/CIS 568)

JavaScript Data Wrangling Resources• https://observablehq.com/@dakoop/learn-js-data • Based on http://learnjsdata.com/ • Good coverage of data wrangling using JavaScript

�3D. Koop, DSC 530, Spring 2019

Page 4: Data Visualization (DSC 530/CIS 568)

Loading Multiple Files• Use Promise.all to load multiple files and then process them all

Promise.all([d3.csv("/data/cities.csv"), d3.tsv("/data/animals.tsv")]) .then(analyze);

function analyze(data) { cities = data[0]; animals = data[1];

console.log(cities[0]); console.log(animals[0]); } => {city: "seattle", state: "WA", population: "652405", land area: "83.9"} {name: "tiger", type: "mammal", avg_weight: "260"}

�4

[http://learnjsdata.com]D. Koop, DSC 530, Spring 2019

Page 5: Data Visualization (DSC 530/CIS 568)

Summarizing Data• d3 has min, max, and extent functions of the form

- 1st argument: dataset - 2nd argument: accessor function

• Example: var landExtent = d3.extent(data, function(d) { return d.land_area; }); console.log(landExtent); => [48.3, 315]

• Summary statistics: - mean, median, deviation - Same format

• Median Example: var landMed = d3.median(data, function(d) { return d.land_area; }); console.log(landMed); => 193.25

�5

[http://learnjsdata.com]D. Koop, DSC 530, Spring 2019

Page 6: Data Visualization (DSC 530/CIS 568)

Nesting Data• Take a flat structure and turn it into something nested • Often similar to a groupby in databases • key indicate groupings • rollup indicates how the groups are processed/aggregated • Last function specifies the data and how the output should look

- entries: [{key: <key>, value: <value>}] - object: {<key>: <value>, …} - map: {<key>: <value>, …} but as a d3.map (safer than object,

but uses get/set instead of square brackets ([])

�6

[http://learnjsdata.com]D. Koop, DSC 530, Spring 2019

Page 7: Data Visualization (DSC 530/CIS 568)

Nesting Example• Data var expenses = [{"name":"jim","amount":34,"date":"11/12/2015"}, {"name":"carl","amount":120.11,"date":"11/12/2015"}, {"name":"jim","amount":45,"date":"12/01/2015"}, {"name":"stacy","amount":12.00,"date":"01/04/2016"}, {"name":"stacy","amount":34.10,"date":"01/04/2016"}, {"name":"stacy","amount":44.80,"date":"01/05/2016"} ];

• Using d3.nest: var expensesAvgAmount = d3.nest() .key(function(d) { return d.name; }) .rollup(function(v) { return d3.mean(v, function(d) { return d.amount; }); }) .entries(expenses); console.log(JSON.stringify(expensesAvgAmount));

• Result: => [{"key":"jim","values":39.5}, {"key":"carl","values":120.11}, {"key":"stacy","values":30.3}]

�7

[http://learnjsdata.com]D. Koop, DSC 530, Spring 2019

Page 8: Data Visualization (DSC 530/CIS 568)

d3-array 2.0 Updates• https://observablehq.com/@d3/d3-array-2-0 • Works with iterables • group and rollup are separate now

�8D. Koop, DSC 530, Spring 2019

Page 9: Data Visualization (DSC 530/CIS 568)

Assignment 4• Filtering: Add population filter • Aggregation: Add histogram of percentage of subsidized housing • Brushing: Filter the map based on histogram

�9D. Koop, DSC 530, Spring 2019

Page 10: Data Visualization (DSC 530/CIS 568)

Projects• Deadlines:

- Presentations on May 6, 3-6pm - Final Reports not late until the end of the day on the 6th

• Design feedback was posted Friday - Good starts, some designs very complete - Usually no scrolling from one view to the next for a multiple-view

visualization, try to fit within a screen - Provide complete overviews, even if interactions will filter views or

provide details

�10D. Koop, DSC 530, Spring 2019

Page 11: Data Visualization (DSC 530/CIS 568)

Fields

• Fields: - Values come from a continuous domain, infinitely many values - Sampled at certain positions to approximate the entire domain - Positions are often aligned in grids - Often measurements of natural or simulated phenomena - Examples: temperature, wind speed, tissue density, pressure,

speed, electrical conductance

�11D. Koop, DSC 530, Spring 2019

Data and Dataset Types

Tables Networks & Trees

Fields Geometry Clusters, Sets, Lists

Items

Attributes

Items (nodes)

Links

Attributes

Grids

Positions

Attributes

Items

Positions

Items

Page 12: Data Visualization (DSC 530/CIS 568)

s0

2

4�00 �01 �02

�10 �11 �12

�20 �21 �22

3

5

2

4v0

v1

v2

3

5

Fields in Visualization

�12D. Koop, DSC 530, Spring 2019

Scalar Fields Vector Fields Tensor Fields(Order-1 Tensor Fields)(Order-0 Tensor Fields) (Order-2+)

Each point in space has an associated...

Scalar

Vector Fields

Vector Tensor

Page 13: Data Visualization (DSC 530/CIS 568)

Grids• Remember we have continuous data and want to sample it in order

to understand the entire domain• Possible schemes?

�13D. Koop, DSC 530, Spring 2019

Page 14: Data Visualization (DSC 530/CIS 568)

Grids• Remember we have continuous data and want to sample it in order

to understand the entire domain• Possible schemes?

• Geometry: the spatial positions of the data (points)• Topology: how the points are connected (cells)• Type of grid determines how much data needs to be stored for both

geometry and topology

�13D. Koop, DSC 530, Spring 2019

Grids (Meshes)• Meshes combine positional information (geometry) with

topological information (connectivity).

• Mesh type can differ substantial depending in the way mesh cells are formed.

From Weiskopf, Machiraju, Möller© Weiskopf/Machiraju/Möller

Data Structures

• Grid types– Grids differ substantially in the cells (basic

building blocks) they are constructed from and in the way the topological information is given

scattered uniform rectilinear structured unstructured[© Weiskopf/Machiraju/Möller]

Page 15: Data Visualization (DSC 530/CIS 568)

Voxels and Cells

�14

10

Voxel vs. Cell model

Represents the 3D division of space by a 3D array of grid points.

gridpoint

VOXEL CELL

gridpoint

• Voxel: grid point in center, constant value in voxel

• Cell: grid points at vertices, value within cell varies

[from http://www.cs.rug.nl/~michael/FANTOM/FANTOM1a.pdf]D. Koop, DSC 530, Spring 2019

Page 16: Data Visualization (DSC 530/CIS 568)

Data• In this lecture, we will be considering scalar data: a single value at

each point • Our data is always discrete, what is the value of a point not exactly

on our grid? • Need a method to determine what these values are: interpolation

schemes

�15D. Koop, DSC 530, Spring 2019

Page 17: Data Visualization (DSC 530/CIS 568)

Interpolation

�16

-1

0

1

1 2 3 4 5 6

D. Koop, DSC 530, Spring 2019

Value at 2.2?

Page 18: Data Visualization (DSC 530/CIS 568)

Nearest Neighbor Interpolation

�17

-1

0

1

1 2 3 4 5 6

D. Koop, DSC 530, Spring 2019

Value at 2.2?

Page 19: Data Visualization (DSC 530/CIS 568)

Linear Interpolation

�18

-1

0

1

1 2 3 4 5 6

D. Koop, DSC 530, Spring 2019

Value at 2.2?

Page 20: Data Visualization (DSC 530/CIS 568)

Interpolation• Other schemes:

- polynomial interpolation - splines - more…

�19D. Koop, DSC 530, Spring 2019

Page 21: Data Visualization (DSC 530/CIS 568)

Dimensions of Data• 1-Dimension: data along a line

- Example: temperature along my drive from Tucson to Dartmouth • 2-Dimensional: data on a plane

- Example: temperature on the surface of a pond • 3-Dimensional: data in our normal world (data in a volume)

- Example: temperature at every point in the room • Complexity increases as we add dimensions • Visualization complexity also increases • Often, want to be able to see phenomena as we see them in real

life settings

�20D. Koop, DSC 530, Spring 2019

Page 22: Data Visualization (DSC 530/CIS 568)

Visualizing Volume (3D) Data

�21

[J. Kniss, 2002]D. Koop, DSC 530, Spring 2019

Page 23: Data Visualization (DSC 530/CIS 568)

Visualizing Volume (3D) Data

�22

[J. Kniss, 2002]D. Koop, DSC 530, Spring 2019

Page 24: Data Visualization (DSC 530/CIS 568)

Visualizing Volume (3D) Data

�23

[J. Kniss, 2002]D. Koop, DSC 530, Spring 2019

Page 25: Data Visualization (DSC 530/CIS 568)

Visualizing Volume (3D) Data

�24

8

Volume Visualization• 2D visualization

slice images (or multi-planar

reformating MPR)

• Indirect 3D visualization

isosurfaces (or surface-shaded

display SSD)

• Direct 3D visualization (direct volume

rendering DVR)

[© Weiskopf/Machiraju/Möller]D. Koop, DSC 530, Spring 2019

Page 26: Data Visualization (DSC 530/CIS 568)

How have we encoded 3D data before? Hint: Think about maps

�25D. Koop, DSC 530, Spring 2019

Page 27: Data Visualization (DSC 530/CIS 568)

Isolines (2D)• Isoline: a line that has the same scalar value at all locations • Example: Topographical Map

�26

[USGS via Wikipedia]D. Koop, DSC 530, Spring 2019

Page 28: Data Visualization (DSC 530/CIS 568)

Isosurfaces (3D)• Isosurface: a surface that has the same scalar value at all locations • Often use multiple isosurfaces to show different levels

�27

[J. Kniss, 2002]D. Koop, DSC 530, Spring 2019

Page 29: Data Visualization (DSC 530/CIS 568)

How?• Given an isovalue, we want to draw the isocontours corresponding

to that value • Remember we only have values defined at grid points • How do we get isolines or isosurfaces from that data? • Can we use the ideas from interpolation?

�28D. Koop, DSC 530, Spring 2019

Page 30: Data Visualization (DSC 530/CIS 568)

Generating Isolines

�29

20 2. Marching Cubes and Variants

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

(a) Scalar grid. (b) The +/− grid.

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

(c) Midpoint vertices. (d) Isocontour.

Figure 2.4. (a) 2D scalar grid. (b) Black vertices are positive. Vertex v with scalarvalue sv is positive if sv >= 5 and negative if sv < 5. Note that sv = 5 for one gridvertex v. (c) Isocontour with vertices at edge midpoints (before linear interpolation).(d) Isocontour with isovalue 5.

isocontours. The isocontour lookup table, Table, contains sixteen entries, one for

each configuration. Each entry, Table[κ] is a list of the E+/−κ pairs.

In Figure 2.3 the isocontour edges are drawn connecting the midpoints ofeach square edge. This is for illustration purposes only. The geometric locationsof the isocontour vertices are not defined by the lookup table.

The isocontour lookup table is constructed on the unit square with vertices(0, 0), (1, 0), (0, 1), (1, 1). To construct the isocontour in grid square (i, j), wehave to map pairs of unit square edges to pairs of square (i, j) edges. Eachvertex v = (vx, vy) of the unit square maps to v + (i, j) = (vx, vy) + (i, j) =(vx + i, vy + j). Each edge e of the unit square with endpoints (v, v′) maps toedge e+ (i, j) = (v + (i, j), v′ + (i, j)). Finally, each edge pair (e1, e2) maps to(e1+ (i, j), e2+ (i, j)).

The endpoints of the isocontour edges are the isocontour vertices. To mapeach isocontour edge to a geometric line segment, we use linear interpolation to

[R. Wenger, 2013]D. Koop, DSC 530, Spring 2019

Page 31: Data Visualization (DSC 530/CIS 568)

Generating Isolines

�30

20 2. Marching Cubes and Variants

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

(a) Scalar grid. (b) The +/− grid.

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

(c) Midpoint vertices. (d) Isocontour.

Figure 2.4. (a) 2D scalar grid. (b) Black vertices are positive. Vertex v with scalarvalue sv is positive if sv >= 5 and negative if sv < 5. Note that sv = 5 for one gridvertex v. (c) Isocontour with vertices at edge midpoints (before linear interpolation).(d) Isocontour with isovalue 5.

isocontours. The isocontour lookup table, Table, contains sixteen entries, one for

each configuration. Each entry, Table[κ] is a list of the E+/−κ pairs.

In Figure 2.3 the isocontour edges are drawn connecting the midpoints ofeach square edge. This is for illustration purposes only. The geometric locationsof the isocontour vertices are not defined by the lookup table.

The isocontour lookup table is constructed on the unit square with vertices(0, 0), (1, 0), (0, 1), (1, 1). To construct the isocontour in grid square (i, j), wehave to map pairs of unit square edges to pairs of square (i, j) edges. Eachvertex v = (vx, vy) of the unit square maps to v + (i, j) = (vx, vy) + (i, j) =(vx + i, vy + j). Each edge e of the unit square with endpoints (v, v′) maps toedge e+ (i, j) = (v + (i, j), v′ + (i, j)). Finally, each edge pair (e1, e2) maps to(e1+ (i, j), e2+ (i, j)).

The endpoints of the isocontour edges are the isocontour vertices. To mapeach isocontour edge to a geometric line segment, we use linear interpolation to

[R. Wenger, 2013]D. Koop, DSC 530, Spring 2019

Page 32: Data Visualization (DSC 530/CIS 568)

Generating Isolines

�31

20 2. Marching Cubes and Variants

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

(a) Scalar grid. (b) The +/− grid.

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

(c) Midpoint vertices. (d) Isocontour.

Figure 2.4. (a) 2D scalar grid. (b) Black vertices are positive. Vertex v with scalarvalue sv is positive if sv >= 5 and negative if sv < 5. Note that sv = 5 for one gridvertex v. (c) Isocontour with vertices at edge midpoints (before linear interpolation).(d) Isocontour with isovalue 5.

isocontours. The isocontour lookup table, Table, contains sixteen entries, one for

each configuration. Each entry, Table[κ] is a list of the E+/−κ pairs.

In Figure 2.3 the isocontour edges are drawn connecting the midpoints ofeach square edge. This is for illustration purposes only. The geometric locationsof the isocontour vertices are not defined by the lookup table.

The isocontour lookup table is constructed on the unit square with vertices(0, 0), (1, 0), (0, 1), (1, 1). To construct the isocontour in grid square (i, j), wehave to map pairs of unit square edges to pairs of square (i, j) edges. Eachvertex v = (vx, vy) of the unit square maps to v + (i, j) = (vx, vy) + (i, j) =(vx + i, vy + j). Each edge e of the unit square with endpoints (v, v′) maps toedge e+ (i, j) = (v + (i, j), v′ + (i, j)). Finally, each edge pair (e1, e2) maps to(e1+ (i, j), e2+ (i, j)).

The endpoints of the isocontour edges are the isocontour vertices. To mapeach isocontour edge to a geometric line segment, we use linear interpolation to

[R. Wenger, 2013]D. Koop, DSC 530, Spring 2019

Page 33: Data Visualization (DSC 530/CIS 568)

Generating Isolines

�32

20 2. Marching Cubes and Variants

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

(a) Scalar grid. (b) The +/− grid.

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

1

2

2

3

3 3

3

4

4

5

6

6

6

6

7

7

7

7

8

8

8

8

8

9

9

(c) Midpoint vertices. (d) Isocontour.

Figure 2.4. (a) 2D scalar grid. (b) Black vertices are positive. Vertex v with scalarvalue sv is positive if sv >= 5 and negative if sv < 5. Note that sv = 5 for one gridvertex v. (c) Isocontour with vertices at edge midpoints (before linear interpolation).(d) Isocontour with isovalue 5.

isocontours. The isocontour lookup table, Table, contains sixteen entries, one for

each configuration. Each entry, Table[κ] is a list of the E+/−κ pairs.

In Figure 2.3 the isocontour edges are drawn connecting the midpoints ofeach square edge. This is for illustration purposes only. The geometric locationsof the isocontour vertices are not defined by the lookup table.

The isocontour lookup table is constructed on the unit square with vertices(0, 0), (1, 0), (0, 1), (1, 1). To construct the isocontour in grid square (i, j), wehave to map pairs of unit square edges to pairs of square (i, j) edges. Eachvertex v = (vx, vy) of the unit square maps to v + (i, j) = (vx, vy) + (i, j) =(vx + i, vy + j). Each edge e of the unit square with endpoints (v, v′) maps toedge e+ (i, j) = (v + (i, j), v′ + (i, j)). Finally, each edge pair (e1, e2) maps to(e1+ (i, j), e2+ (i, j)).

The endpoints of the isocontour edges are the isocontour vertices. To mapeach isocontour edge to a geometric line segment, we use linear interpolation to

[R. Wenger, 2013]D. Koop, DSC 530, Spring 2019

Page 34: Data Visualization (DSC 530/CIS 568)

Marching Squares

�33

26 2. Marching Cubes and Variants

6 7 81 2 3 4 5

14 15 169 10 11 12 13

Figure 2.10. Red, positive regions and blue, negative regions for each square configu-ration. The green isocontour is part of the positive region. Black vertices are positive.

Proof of Properties 1 & 2: The Marching Squares isocontour consists of a finiteset of line segments, so it is piecewise linear. These line segments intersect only attheir endpoints and thus form a triangulation of the isocontour. The endpointsof these line segments lie on the grid edges, confirming Property 2. !

Property 3. The isocontour intersects every bipolar grid edge at exactly onepoint.

Property 4. The isocontour does not intersect any negative or strictly positivegrid edges.

Proof of Properties 3 & 4: Each isocontour edge is contained in a grid square. Sincethe grid squares are convex, only isocontour edges with endpoints (vertices) onthe grid edge intersect the grid edge. If the grid edge has one positive and onenegative endpoint, the unique location of the isocontour vertex on the grid edgeis determined by linear interpolation. Thus the isocontour intersects a bipolargrid edge at only one point.

If the grid edge is negative or strictly positive, then no isocontour vertex lieson the grid edge. Thus the isocontour does not intersect negative or strictlypositive grid edges. !

Within each grid square the isocontour partitions the grid square into tworegions. Let the positive region for a grid square c be the set of points which canbe reached by a path ζ from a positive vertex. More precisely, a point p is in thepositive region of c if there is some path ζ ⊂ c connecting p to a positive vertexof c such that the interior of ζ does not intersect the isocontour. A point p isin the negative region of c if there is some path ζ ⊂ c connecting p to a negativevertex of c such that ζ does not intersect the isocontour. Since any path ζ ⊂ cfrom a positive to a negative vertex must intersect the isocontour, the positiveand negative regions form a partition of the square c. Figure 2.10 illustrates thepositive and negative regions, colored red and blue, respectively, for each squareconfiguration.

[R. Wenger, 2013]D. Koop, DSC 530, Spring 2019

Page 35: Data Visualization (DSC 530/CIS 568)

Ambiguous Configurations• There are some cases for which we cannot tell which way to draw

the isolines…

�34

[R. Wenger, 2013]D. Koop, DSC 530, Spring 2019

30 2. Marching Cubes and Variants

8−I 16−I 16−II8−II

168

Figure 2.12. Ambiguous square configurations.

14

2

22 2

1121

2

2

4

2

1

1

14

2

22 2

1121

2

2

4

2

1

1

Figure 2.13. Topologically distinct isocontours created by using different isocontoursfor the ambiguous configuration in the central grid square.

scalar grid with two topologically distinct isocontours created by different resolu-tions of the ambiguous configurations. The first isocontour has two componentswhile the second has one.

While the choice of isocontours for the ambiguous configurations changesthe isocontour topology, any of the choices will produce isocontours that are 1-manifolds and strictly separate strictly positive vertices from negative vertices.As we shall see, this is not true in three dimensions.

2.3 Marching Cubes

2.3.1 Algorithm

The three-dimensional Marching Cubes algorithm follows precisely the stepsin the two-dimensional Marching Squares algorithm. Input to the March-

Page 36: Data Visualization (DSC 530/CIS 568)

Ambiguous Configurations• Either works for marching squares, this isn't the case for 3D

�35

[R. Wenger, 2013]D. Koop, DSC 530, Spring 2019

30 2. Marching Cubes and Variants

8−I 16−I 16−II8−II

168

Figure 2.12. Ambiguous square configurations.

14

2

22 2

1121

2

2

4

2

1

1

14

2

22 2

1121

2

2

4

2

1

1

Figure 2.13. Topologically distinct isocontours created by using different isocontoursfor the ambiguous configuration in the central grid square.

scalar grid with two topologically distinct isocontours created by different resolu-tions of the ambiguous configurations. The first isocontour has two componentswhile the second has one.

While the choice of isocontours for the ambiguous configurations changesthe isocontour topology, any of the choices will produce isocontours that are 1-manifolds and strictly separate strictly positive vertices from negative vertices.As we shall see, this is not true in three dimensions.

2.3 Marching Cubes

2.3.1 Algorithm

The three-dimensional Marching Cubes algorithm follows precisely the stepsin the two-dimensional Marching Squares algorithm. Input to the March-

Page 37: Data Visualization (DSC 530/CIS 568)

3D: Marching Cubes• Same idea, more cases [Lorensen and Cline, 1987]

�36

[R. Wenger, 2013]D. Koop, DSC 530, Spring 2019

2.3. Marching Cubes 33

# PositiveVertices

Zero

One

Two

Three

Four

Five

Six

Seven

Eight

2A 2C

0

1

3A 3B 3C

4A 4B 4C 4D 4E 4F

5A 5B 5C

6A 6B 6C

7

8

2B

Figure 2.16. Isosurfaces for twenty-two distinct cube configurations.

2.3. Marching Cubes 33

# PositiveVertices

Zero

One

Two

Three

Four

Five

Six

Seven

Eight

2A 2C

0

1

3A 3B 3C

4A 4B 4C 4D 4E 4F

5A 5B 5C

6A 6B 6C

7

8

2B

Figure 2.16. Isosurfaces for twenty-two distinct cube configurations.

Page 38: Data Visualization (DSC 530/CIS 568)

Incompatible Choices• If we have ambiguous cases where we choose differently for each

cell, the surfaces will not match up correctly—there are holes • Fix with the asymptotic decider [Nielson and Hamann,1991]

�37

[R. Wenger, 2013]D. Koop, DSC 530, Spring 2019

34 2. Marching Cubes and Variants

(a) (b)

Figure 2.17. (a) Adjacent configurations sharing a common face. (b) Incompatibleisosurface patches for the adjacent configurations.

Figure 2.18. Compatible isosurface patches for adjacent configurations in Fig-ure 2.17(a).

configuration κ. The isosurface patch intersects every edge of E+/−κ exactly once

and does not intersect any other grid cube edges.To define the 256 entries in the table, it is only necessary to determine the

table entries for the twenty-two distinct configurations. The table entries forthe other configurations can be derived using rotation and reflection symme-try. Figure 2.16 contains the twenty-two distinct cube configurations and theirisosurfaces.

The isosurface lookup table is constructed on the unit cube with vertices(0, 0, 0), (1, 0, 0), (0, 1, 0), . . . , (0, 1, 1), (1, 1, 1). To construct the isosurface in gridcube (i, j, k), we have to map unit cube edges to edges of cube (i, j, k). Eachvertex v = (vx, vy, vz) of the unit cube maps to v + (i, j, k) = (vx, vy, vz) +(i, j, k) = (vx + i, vy + j, vz + k). Each edge e of the unit square with endpoints(v, v′) maps to edge e + (i, j, k) = (v + (i, j, k), v′ + (i, j, k)). Finally, each edgetriple (e1, e2, e3) maps to (e1+ (i, j, k), e2+ (i, j, k), e3+ (i, j, k)).

In Figure 2.16, the isosurface vertices lie on the midpoints of the grid edges.This is for illustration purposes only. The geometric locations of the isosurfacevertices are not defined by the lookup table.

The vertices of the isosurface triangles are the isosurface vertices. To mapeach isosurface triangle to a geometric triangle, we use linear interpolation toposition the isosurface vertices as described in Section 1.7.2. Each isosurfacevertex v lies on a grid edge [p, q]. If sp and sq are the scalar values at p and qand σ is the isovalue, then map v to (1− α)p+ q where α = (σ − sp)/(sq − sp).

Page 39: Data Visualization (DSC 530/CIS 568)

Marching Cubes Algorithm• For each cell:

- Classify each vertex as inside or outside (>=, <) — 0 or 1 - Take the eight vertex classifications as a bit string - Use the bit string as a lookup into a table to get edges - Interpolate to get actual edge locations - Compute gradients - Resolve ambiguities

• Render a bunch of triangles: easy for graphics cards

�38D. Koop, DSC 530, Spring 2019

Page 40: Data Visualization (DSC 530/CIS 568)

Multiple Isosurfaces• Topographical maps have multiple

isolines to show elevation trends • Problem in 3D? Occlusion • Solution? Transparent surfaces • Issues:

- Think about color in order to make each surface visible

- Compositing: how do colors "add up" with multiple surfaces

- How to determine good isovalues?

• Next: - Direct Volume Rendering

�39

[J. Kniss, 2002]D. Koop, DSC 530, Spring 2019