Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
1febb304
Commit
1febb304
authored
Nov 21, 2010
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Graphics assignment 9.
Source code cleanup.
parent
eefbd269
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
73 deletions
+29
-73
graphics/ass9/source/marching_tetrahedra.c
graphics/ass9/source/marching_tetrahedra.c
+25
-69
graphics/ass9/source/volume.c
graphics/ass9/source/volume.c
+4
-4
No files found.
graphics/ass9/source/marching_tetrahedra.c
View file @
1febb304
...
@@ -44,18 +44,17 @@ interpolate_points(unsigned char isovalue, vec3 p1, vec3 p2,
...
@@ -44,18 +44,17 @@ interpolate_points(unsigned char isovalue, vec3 p1, vec3 p2,
2 triangles.
2 triangles.
*/
*/
/
/ Some abbreviating definitions that are used in the function below
/
* Some abbreviating definitions that are used in the function below */
#define ADD_VEC(i,a,b) (triangles[tri_count].p[(i)] = \
#define ADD_VEC(i,a,b) (triangles[tri_count].p[(i)] = \
interpolate_points(isovalue, c.p[(a)], c.p[(b)], v[(a)], v[(b)]))
interpolate_points(isovalue, c.p[(a)], c.p[(b)], v[(a)], v[(b)]))
#define ADD_TRI(a,b,c,d,e,f) \
#define ADD_TRI(a,b,c,d,e,f) \
ADD_VEC(0,(a),(b)); ADD_VEC(1,(c),(d)); ADD_VEC(2,(e),(f)); tri_count++
ADD_VEC(0,(a),(b)); ADD_VEC(1,(c),(d)); ADD_VEC(2,(e),(f)); tri_count++
static
int
static
int
generate_tetrahedron_triangles
(
triangle
*
triangles
,
unsigned
char
isovalue
,
generate_tetrahedron_triangles
(
triangle
*
triangles
,
unsigned
char
isovalue
,
cell
c
,
int
v0
,
int
v1
,
int
v2
,
int
v3
)
cell
c
,
int
v0
,
int
v1
,
int
v2
,
int
v3
)
{
{
unsigned
char
*
v
=
c
.
value
;
unsigned
char
*
v
=
c
.
value
;
//vec3 *p = triangles[0].p;
int
tri_count
=
0
;
int
tri_count
=
0
;
// 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
...
@@ -63,72 +62,29 @@ generate_tetrahedron_triangles(triangle *triangles, unsigned char isovalue,
...
@@ -63,72 +62,29 @@ generate_tetrahedron_triangles(triangle *triangles, unsigned char isovalue,
switch
(
(
v
[
v0
]
<=
isovalue
?
1
:
0
)
|
(
v
[
v1
]
<=
isovalue
?
1
<<
1
:
0
)
switch
(
(
v
[
v0
]
<=
isovalue
?
1
:
0
)
|
(
v
[
v1
]
<=
isovalue
?
1
<<
1
:
0
)
|
(
v
[
v2
]
<=
isovalue
?
1
<<
2
:
0
)
|
(
v
[
v3
]
<=
isovalue
?
1
<<
3
:
0
)
)
|
(
v
[
v2
]
<=
isovalue
?
1
<<
2
:
0
)
|
(
v
[
v3
]
<=
isovalue
?
1
<<
3
:
0
)
)
{
{
case
0x1
:
case
0xE
:
// 0001 or 1110
case
0x1
:
case
0xE
:
// 0001 or 1110
ADD_TRI
(
v0
,
v1
,
v0
,
v2
,
v0
,
v3
);
ADD_TRI
(
v0
,
v1
,
v0
,
v2
,
v0
,
v3
);
break
;
break
;
//p[0] = interpolate_points(isovalue, c.p[v0], c.p[v1], v[v0], v[v1]);
case
0x2
:
case
0xD
:
// 0010 or 1101
//p[1] = interpolate_points(isovalue, c.p[v0], c.p[v2], v[v0], v[v2]);
ADD_TRI
(
v1
,
v0
,
v1
,
v3
,
v1
,
v2
);
//p[2] = interpolate_points(isovalue, c.p[v0], c.p[v3], v[v0], v[v3]);
break
;
//return 1;
case
0x4
:
case
0xB
:
// 0100 or 1011
case
0x2
:
case
0xD
:
// 0010 or 1101
ADD_TRI
(
v2
,
v0
,
v2
,
v1
,
v2
,
v3
);
ADD_TRI
(
v1
,
v0
,
v1
,
v3
,
v1
,
v2
);
break
;
break
;
case
0x8
:
case
0x7
:
// 1000 or 0111
//p[0] = interpolate_points(isovalue, c.p[v1], c.p[v0], v[v1], v[v0]);
ADD_TRI
(
v3
,
v0
,
v3
,
v2
,
v3
,
v1
);
//p[1] = interpolate_points(isovalue, c.p[v1], c.p[v3], v[v1], v[v3]);
break
;
//p[2] = interpolate_points(isovalue, c.p[v1], c.p[v2], v[v1], v[v2]);
case
0x3
:
case
0xC
:
// 0011 or 1100
//return 1;
ADD_TRI
(
v0
,
v3
,
v0
,
v2
,
v1
,
v3
);
case
0x4
:
case
0xB
:
// 0100 or 1011
ADD_TRI
(
v1
,
v3
,
v0
,
v2
,
v1
,
v2
);
ADD_TRI
(
v2
,
v0
,
v2
,
v1
,
v2
,
v3
);
break
;
break
;
case
0x5
:
case
0xA
:
// 0101 or 1010
//p[0] = interpolate_points(isovalue, c.p[v2], c.p[v0], v[v2], v[v0]);
ADD_TRI
(
v0
,
v1
,
v2
,
v3
,
v0
,
v3
);
//p[1] = interpolate_points(isovalue, c.p[v2], c.p[v1], v[v2], v[v1]);
ADD_TRI
(
v0
,
v1
,
v1
,
v2
,
v2
,
v3
);
//p[2] = interpolate_points(isovalue, c.p[v2], c.p[v3], v[v2], v[v3]);
break
;
//return 1;
case
0x6
:
case
0x9
:
// 0110 or 1001
case
0x8
:
case
0x7
:
// 1000 or 0111
ADD_TRI
(
v0
,
v1
,
v2
,
v3
,
v1
,
v3
);
ADD_TRI
(
v3
,
v0
,
v3
,
v2
,
v3
,
v1
);
ADD_TRI
(
v0
,
v1
,
v0
,
v2
,
v2
,
v3
);
break
;
//p[0] = interpolate_points(isovalue, c.p[v3], c.p[v0], v[v3], v[v0]);
//p[1] = interpolate_points(isovalue, c.p[v3], c.p[v2], v[v3], v[v2]);
//p[2] = interpolate_points(isovalue, c.p[v3], c.p[v1], v[v3], v[v1]);
//return 1;
case
0x3
:
case
0xC
:
// 0011 or 1100
ADD_TRI
(
v0
,
v3
,
v0
,
v2
,
v1
,
v3
);
ADD_TRI
(
v1
,
v3
,
v0
,
v2
,
v1
,
v2
);
break
;
//p[0] = interpolate_points(isovalue, c.p[v0], c.p[v3], v[v0], v[v3]);
//p[1] = interpolate_points(isovalue, c.p[v0], c.p[v2], v[v0], v[v2]);
//p[2] = interpolate_points(isovalue, c.p[v1], c.p[v3], v[v1], v[v3]);
//p = triangles[1].p;
//p[0] = interpolate_points(isovalue, c.p[v1], c.p[v3], v[v1], v[v3]);
//p[2] = interpolate_points(isovalue, c.p[v1], c.p[v2], v[v1], v[v2]);
//p[1] = interpolate_points(isovalue, c.p[v0], c.p[v2], v[v0], v[v2]);
//return 2;
case
0x5
:
case
0xA
:
// 0101 or 1010
ADD_TRI
(
v0
,
v1
,
v2
,
v3
,
v0
,
v3
);
ADD_TRI
(
v0
,
v1
,
v1
,
v2
,
v2
,
v3
);
break
;
//p[0] = interpolate_points(isovalue, c.p[v0], c.p[v1], v[v0], v[v1]);
//p[1] = interpolate_points(isovalue, c.p[v2], c.p[v3], v[v2], v[v3]);
//p[2] = interpolate_points(isovalue, c.p[v0], c.p[v3], v[v0], v[v3]);
//p = triangles[1].p;
//p[0] = interpolate_points(isovalue, c.p[v0], c.p[v1], v[v0], v[v1]);
//p[1] = interpolate_points(isovalue, c.p[v1], c.p[v2], v[v1], v[v2]);
//p[2] = interpolate_points(isovalue, c.p[v2], c.p[v3], v[v2], v[v3]);
//return 2;
case
0x6
:
case
0x9
:
// 0110 or 1001
ADD_TRI
(
v0
,
v1
,
v2
,
v3
,
v1
,
v3
);
ADD_TRI
(
v0
,
v1
,
v0
,
v2
,
v2
,
v3
);
break
;
//p[0] = interpolate_points(isovalue, c.p[v0], c.p[v1], v[v0], v[v1]);
//p[2] = interpolate_points(isovalue, c.p[v1], c.p[v3], v[v1], v[v3]);
//p[1] = interpolate_points(isovalue, c.p[v2], c.p[v3], v[v2], v[v3]);
//p = triangles[1].p;
//p[0] = interpolate_points(isovalue, c.p[v0], c.p[v1], v[v0], v[v1]);
//p[1] = interpolate_points(isovalue, c.p[v0], c.p[v2], v[v0], v[v2]);
//p[2] = interpolate_points(isovalue, c.p[v2], c.p[v3], v[v2], v[v3]);
//return 2;
default:
// 0000 or 1111
break
;
}
}
return
tri_count
;
return
tri_count
;
...
...
graphics/ass9/source/volume.c
View file @
1febb304
...
@@ -35,7 +35,7 @@ voxel2idx(int i, int j, int k)
...
@@ -35,7 +35,7 @@ voxel2idx(int i, int j, int k)
cell corresponds to voxel (i, j, k), datapoint 1 to voxel (i+1, j, k),
cell corresponds to voxel (i, j, k), datapoint 1 to voxel (i+1, j, k),
etc. See Figure 3 in the assignment. */
etc. See Figure 3 in the assignment. */
/
/ Abbreviation definition, used in the function below
/
* Abbreviation definition, used in the function below */
#define ADD_DATA_POINT(index,i,j,k) \
#define ADD_DATA_POINT(index,i,j,k) \
c.p[(index)] = v3_create((i), (j), (k)); \
c.p[(index)] = v3_create((i), (j), (k)); \
c.value[(index)] = volume[voxel2idx((i), (j), (k))]
c.value[(index)] = volume[voxel2idx((i), (j), (k))]
...
@@ -43,8 +43,8 @@ voxel2idx(int i, int j, int k)
...
@@ -43,8 +43,8 @@ voxel2idx(int i, int j, int k)
cell
cell
get_cell
(
int
i
,
int
j
,
int
k
)
get_cell
(
int
i
,
int
j
,
int
k
)
{
{
cell
c
;
cell
c
;
ADD_DATA_POINT
(
0
,
i
,
j
,
k
);
ADD_DATA_POINT
(
0
,
i
,
j
,
k
);
ADD_DATA_POINT
(
1
,
i
+
1
,
j
,
k
);
ADD_DATA_POINT
(
1
,
i
+
1
,
j
,
k
);
ADD_DATA_POINT
(
2
,
i
,
j
+
1
,
k
);
ADD_DATA_POINT
(
2
,
i
,
j
+
1
,
k
);
...
@@ -54,7 +54,7 @@ get_cell(int i, int j, int k)
...
@@ -54,7 +54,7 @@ get_cell(int i, int j, int k)
ADD_DATA_POINT
(
6
,
i
,
j
+
1
,
k
+
1
);
ADD_DATA_POINT
(
6
,
i
,
j
+
1
,
k
+
1
);
ADD_DATA_POINT
(
7
,
i
+
1
,
j
+
1
,
k
+
1
);
ADD_DATA_POINT
(
7
,
i
+
1
,
j
+
1
,
k
+
1
);
return
c
;
return
c
;
}
}
/* Utility function to read a volume dataset from a VTK file.
/* Utility function to read a volume dataset from a VTK file.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment