Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/2dtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libfontconfig1-dev

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy

- name: Cache dependencies
uses: Swatinem/rust-cache@v2

- name: Check with cargo
run: cargo check

- name: Test with cargo
run: cargo test

- name: Cache dependencies
uses: Swatinem/rust-cache@v1
5 changes: 4 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libfontconfig1-dev

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.70.0
toolchain: stable
components: rustfmt, clippy

- name: Cache dependencies
Expand Down
236 changes: 202 additions & 34 deletions benches/mesh_benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,116 @@ fn bench_bowyer_watson_3d(c: &mut Criterion) {

fn bench_advancing_front(c: &mut Criterion) {
let p = [
Point3D { index: 0, x: 0.0, y: 0.0, z: 0.0 },
Point3D { index: 1, x: 1.0, y: 0.0, z: 0.0 },
Point3D { index: 2, x: 1.0, y: 1.0, z: 0.0 },
Point3D { index: 3, x: 0.0, y: 1.0, z: 0.0 },
Point3D { index: 4, x: 0.0, y: 0.0, z: 1.0 },
Point3D { index: 5, x: 1.0, y: 0.0, z: 1.0 },
Point3D { index: 6, x: 1.0, y: 1.0, z: 1.0 },
Point3D { index: 7, x: 0.0, y: 1.0, z: 1.0 },
Point3D {
index: 0,
x: 0.0,
y: 0.0,
z: 0.0,
},
Point3D {
index: 1,
x: 1.0,
y: 0.0,
z: 0.0,
},
Point3D {
index: 2,
x: 1.0,
y: 1.0,
z: 0.0,
},
Point3D {
index: 3,
x: 0.0,
y: 1.0,
z: 0.0,
},
Point3D {
index: 4,
x: 0.0,
y: 0.0,
z: 1.0,
},
Point3D {
index: 5,
x: 1.0,
y: 0.0,
z: 1.0,
},
Point3D {
index: 6,
x: 1.0,
y: 1.0,
z: 1.0,
},
Point3D {
index: 7,
x: 0.0,
y: 1.0,
z: 1.0,
},
];
let faces = vec![
Face { a: p[0], b: p[1], c: p[2] }, Face { a: p[0], b: p[2], c: p[3] },
Face { a: p[4], b: p[6], c: p[5] }, Face { a: p[4], b: p[7], c: p[6] },
Face { a: p[0], b: p[5], c: p[1] }, Face { a: p[0], b: p[4], c: p[5] },
Face { a: p[2], b: p[7], c: p[3] }, Face { a: p[2], b: p[6], c: p[7] },
Face { a: p[0], b: p[3], c: p[7] }, Face { a: p[0], b: p[7], c: p[4] },
Face { a: p[1], b: p[5], c: p[6] }, Face { a: p[1], b: p[6], c: p[2] },
Face {
a: p[0],
b: p[1],
c: p[2],
},
Face {
a: p[0],
b: p[2],
c: p[3],
},
Face {
a: p[4],
b: p[6],
c: p[5],
},
Face {
a: p[4],
b: p[7],
c: p[6],
},
Face {
a: p[0],
b: p[5],
c: p[1],
},
Face {
a: p[0],
b: p[4],
c: p[5],
},
Face {
a: p[2],
b: p[7],
c: p[3],
},
Face {
a: p[2],
b: p[6],
c: p[7],
},
Face {
a: p[0],
b: p[3],
c: p[7],
},
Face {
a: p[0],
b: p[7],
c: p[4],
},
Face {
a: p[1],
b: p[5],
c: p[6],
},
Face {
a: p[1],
b: p[6],
c: p[2],
},
];
let points = p.to_vec();
c.bench_function("advancing_front (cube)", |b| {
Expand All @@ -59,44 +153,118 @@ fn bench_advancing_front(c: &mut Criterion) {
}

fn bench_octree(c: &mut Criterion) {
let min = Point3D { index: 0, x: -1.0, y: -1.0, z: -1.0 };
let max = Point3D { index: 0, x: 1.0, y: 1.0, z: 1.0 };
let min = Point3D {
index: 0,
x: -1.0,
y: -1.0,
z: -1.0,
};
let max = Point3D {
index: 0,
x: 1.0,
y: 1.0,
z: 1.0,
};
c.bench_function("octree_mesh (depth=3, sphere)", |b| {
b.iter(|| octree_mesh(black_box(min), black_box(max), 3, &|p| {
p.x * p.x + p.y * p.y + p.z * p.z <= 1.0
}))
b.iter(|| {
octree_mesh(black_box(min), black_box(max), 3, &|p| {
p.x * p.x + p.y * p.y + p.z * p.z <= 1.0
})
})
});
}

fn bench_marching_cubes(c: &mut Criterion) {
let min = Point3D { index: 0, x: -2.0, y: -2.0, z: -2.0 };
let max = Point3D { index: 0, x: 2.0, y: 2.0, z: 2.0 };
let min = Point3D {
index: 0,
x: -2.0,
y: -2.0,
z: -2.0,
};
let max = Point3D {
index: 0,
x: 2.0,
y: 2.0,
z: 2.0,
};
let field = |x: f64, y: f64, z: f64| x * x + y * y + z * z - 1.0;
c.bench_function("marching_cubes (20^3, sphere)", |b| {
b.iter(|| marching_cubes(20, 20, 20, black_box(min), black_box(max), &field, 0.0))
});
}

fn bench_voxel_mesh(c: &mut Criterion) {
let min = Point3D { index: 0, x: -1.0, y: -1.0, z: -1.0 };
let max = Point3D { index: 0, x: 1.0, y: 1.0, z: 1.0 };
let min = Point3D {
index: 0,
x: -1.0,
y: -1.0,
z: -1.0,
};
let max = Point3D {
index: 0,
x: 1.0,
y: 1.0,
z: 1.0,
};
c.bench_function("voxel_mesh (8^3, sphere)", |b| {
b.iter(|| voxel_mesh(black_box(min), black_box(max), 8, 8, 8, &|p| {
p.x * p.x + p.y * p.y + p.z * p.z <= 1.0
}))
b.iter(|| {
voxel_mesh(black_box(min), black_box(max), 8, 8, 8, &|p| {
p.x * p.x + p.y * p.y + p.z * p.z <= 1.0
})
})
});
}

fn bench_delaunay_refinement(c: &mut Criterion) {
let points = vec![
Point3D { index: 0, x: 0.0, y: 0.0, z: 0.0 },
Point3D { index: 1, x: 1.0, y: 0.0, z: 0.0 },
Point3D { index: 2, x: 0.0, y: 1.0, z: 0.0 },
Point3D { index: 3, x: 1.0, y: 1.0, z: 0.0 },
Point3D { index: 4, x: 0.0, y: 0.0, z: 1.0 },
Point3D { index: 5, x: 1.0, y: 0.0, z: 1.0 },
Point3D { index: 6, x: 0.0, y: 1.0, z: 1.0 },
Point3D { index: 7, x: 1.0, y: 1.0, z: 1.0 },
Point3D {
index: 0,
x: 0.0,
y: 0.0,
z: 0.0,
},
Point3D {
index: 1,
x: 1.0,
y: 0.0,
z: 0.0,
},
Point3D {
index: 2,
x: 0.0,
y: 1.0,
z: 0.0,
},
Point3D {
index: 3,
x: 1.0,
y: 1.0,
z: 0.0,
},
Point3D {
index: 4,
x: 0.0,
y: 0.0,
z: 1.0,
},
Point3D {
index: 5,
x: 1.0,
y: 0.0,
z: 1.0,
},
Point3D {
index: 6,
x: 0.0,
y: 1.0,
z: 1.0,
},
Point3D {
index: 7,
x: 1.0,
y: 1.0,
z: 1.0,
},
];
c.bench_function("delaunay_refinement (cube, ratio=2.0)", |b| {
b.iter(|| delaunay_refinement(black_box(points.clone()), 2.0))
Expand Down
Loading