Commit ac621031 authored by Sander Mathijs van Veen's avatar Sander Mathijs van Veen

Merge branch 'master' of ssh://vo20.nl/git/uva

parents 4b94caaa d7ca18f4
...@@ -5,13 +5,10 @@ ...@@ -5,13 +5,10 @@
* Date ............ 29.10.2007 * Date ............ 29.10.2007
* Created by ...... Paul Melis * Created by ...... Paul Melis
* *
* Student name .... * Student name .... Sander van Veen & Taddeus Kroes
* Student email ... * Student email ... sandervv@gmail.com & taddeuskroes@hotmail.com
* Collegekaart .... * Collegekaart .... 6169676 & 6054129
* Date ............ * Date ............ 17.11.2010
* Comments ........
*
* (always fill in these fields before submitting!!)
*/ */
#include <stdio.h> #include <stdio.h>
......
/* Computer Graphics, Assignment, Volume rendering with cubes/points/isosurface /* Computer Graphics, Assignment, Volume rendering with cubes/points/isosurface
* *
* Student name .... * Student name .... Sander van Veen & Taddeus Kroes
* Student email ... * Student email ... sandervv@gmail.com & taddeuskroes@hotmail.com
* Collegekaart .... * Collegekaart .... 6169676 & 6054129
* Date ............ * Date ............ 17.11.2010
* Comments ........
*
* (always fill in these fields before submitting!!)
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <math.h>
#include "marching_tetrahedra.h" #include "marching_tetrahedra.h"
/* Compute a linearly interpolated position where an isosurface cuts /* Compute a linearly interpolated position where an isosurface cuts
...@@ -23,13 +19,13 @@ static vec3 ...@@ -23,13 +19,13 @@ static vec3
interpolate_points(unsigned char isovalue, vec3 p1, vec3 p2, interpolate_points(unsigned char isovalue, vec3 p1, vec3 p2,
unsigned char v1, unsigned char v2) unsigned char v1, unsigned char v2)
{ {
//float diff1 = fabsf((float)(isovalue - v1)), // Interpolate between v1 and v2 to determine relative coordinates
// diff2 = fabsf((float)(isovalue - v2)), vec3 v = v3_multiply(v3_add(
// total = diff1 + diff2; v3_multiply(p1, v2 - isovalue),
//vec3 v = v3_add(v3_multiply(p1, diff1/total), v3_multiply(p2, diff2/total)); v3_multiply(p2, isovalue - v1)
), 1.0 / (v2 - v1));
vec3 v = v3_add(v3_multiply(p1, 0.5), v3_multiply(p2, 0.5));
// Multiply by voxel dimensions for absolute coordinates
return v3_create(v.x * sizex, v.y * sizey, v.z * sizez); return v3_create(v.x * sizex, v.y * sizey, v.z * sizez);
} }
...@@ -59,10 +55,12 @@ generate_tetrahedron_triangles(triangle *triangles, unsigned char isovalue, ...@@ -59,10 +55,12 @@ generate_tetrahedron_triangles(triangle *triangles, unsigned char isovalue,
// Use a 4-bit bitmask to determine the order of "black/white" points of // Use a 4-bit bitmask to determine the order of "black/white" points of
// the tetrahedon. Generate 0, 1 or 2 triangle(s) according to the case. // the tetrahedon. Generate 0, 1 or 2 triangle(s) according to the case.
switch( (v[v0] <= isovalue ? 1 : 0) | (v[v1] <= isovalue ? 1<<1 : 0) switch( (v[v0] <= isovalue ? 1 : 0) | (v[v1] <= isovalue ? 2 : 0)
| (v[v2] <= isovalue ? 1<<2 : 0) | (v[v3] <= isovalue ? 1<<3 : 0) ) | (v[v2] <= isovalue ? 4 : 0) | (v[v3] <= isovalue ? 8 : 0) )
{ {
case 0x1: case 0xE: // 0001 or 1110 case 0x1: case 0xE: // 0001 or 1110
// ADD_TRI usage example: interpolate between edges (v0, v1),
// (v0, v2) and (v0, v3)
ADD_TRI(v0, v1, v0, v2, v0, v3); ADD_TRI(v0, v1, v0, v2, v0, v3);
break; break;
case 0x2: case 0xD: // 0010 or 1101 case 0x2: case 0xD: // 0010 or 1101
......
Question 1:
What happens for case 0011/1100 when two of the tetrahedron's vertex
values are equal to the iso-value of interest and the other two are greater
than the iso-value? Is this a bad thing? Hint: think of the kind of output
generated in this case.
In that case, two corners of the same triangle are equal to the tetrahedon
vertices that are equal to the isovalue, so an edge of the triangle is
exactly on the edge of the tetrahedon between the two equal vertices. In the
interpolation function, this means a division by zero (v2 - v1 = 0), which
is indeed a bad thing. A solution to this problem would build in an extra
check for this kind of cases.
--------------------------------------------------------------------------------
Question 2:
We render the iso-surface two-sided here, that is, without back-face culling.
But if the iso-surface were to form a closed surface there would be no need
for this, as the inside/back-side of the surface would never be visible. So
for what situation does marching tetrahedra not produce a closed isosurface?
For each triangle edge in a tetrahedon, there should be a triangle in one
of the neighbouring tetrahedons that shares that edge. Because of the
shapes of the tetrahedons, this means that the end points of the edge are
the result of interpolation in both tetrahedons (which can be checked in
code relatively easily). For example, this situation occurs in a dataset
containing a cube or a sphere.
--------------------------------------------------------------------------------
Question 3:
What optimizations to the marching tetrahedrons algorithm as described
in Section 3 can you think of? Are there computations that are performed
redundantly? Is there opportunity for parallel processing?
- There's plenty of room for parallel processing, since all cells/tetrahedons
are checked independently of eachother.
- If we know (by specification) that an isosurface is closed, we can use the
property described in the answer to question 2 by creating an incremental
algorithm that uses already interpolated points in neigbouring tetrahedons
to create a triangle strip, instead of interpolating seperately in each
tetrahedon (note that there is less room for parallel processing in this case).
/* Computer Graphics, Assignment, Volume rendering with cubes/points/isosurface /* Computer Graphics, Assignment, Volume rendering with cubes/points/isosurface
* *
* Student name .... * Student name .... Sander van Veen & Taddeus Kroes
* Student email ... * Student email ... sandervv@gmail.com & taddeuskroes@hotmail.com
* Collegekaart .... * Collegekaart .... 6169676 & 6054129
* Date ............ * Date ............ 17.11.2010
* Comments ........
*
* (always fill in these fields before submitting!!)
*/ */
#include <stdio.h> #include <stdio.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment