Commit 0fe4d1ab authored by SirBlueRabbit's avatar SirBlueRabbit
Browse files

fixed 23 move

parent c93b8171
......@@ -86,22 +86,22 @@ impl Triangulation {
fn move_23(&mut self, label: Label<HalfEdge>) {
// identify halfedges
let a = label.adj_int();
let b = label.adj_ext(&self.half_edges).next().adj_int();
let a = label;
let b = label.adj_ext(&self.half_edges).next();
// identify vertices
let v0 = self.half_edges[a.next()].vertex_head;
let v1 = self.half_edges[label].vertex_head;
let v0 = self.half_edges[a.adj_int().next()].vertex_head;
let v1 = self.half_edges[a].vertex_tail;
let v2 = self.half_edges[a].vertex_head;
let v3 = self.half_edges[b].vertex_head;
let v4 = self.half_edges[b.next()].vertex_head;
let v4 = self.half_edges[b.adj_int().next()].vertex_head;
// identify old boundary
let boundary2 = [
label.next().next().adj_int(),
label.next().adj_int(),
label.adj_ext(&self.half_edges).adj_int(),
label.adj_ext(&self.half_edges).next().next().adj_int(),
a.next().adj_int(),
a.next().next().adj_int(),
b.next().adj_int(),
b.next().next().adj_int(),
];
// create dummy simplex
......@@ -120,15 +120,20 @@ impl Triangulation {
}
// insert new tetrahedron and match vertices
let c = self.insert_tet([v3, v1, v0, v4]);
self.half_edges.set_vertices(a, [v1, v2, v0, v4]);
self.half_edges.set_vertices(b, [v3, v2, v4, v0]);
let c = self.insert_tet([v4, v0, v2, v3]);
self.half_edges.set_vertices(a, [v1, v2, v4, v0]);
self.half_edges.set_vertices(b, [v1, v3, v0, v4]);
// identify new boundary
let boundary3 = [b.adj_int(), c, a.adj_int(), c.adj_int()];
let boundary3 = [
c.adj_int().next().next().adj_int().next(),
b,
c.next().next().adj_int().next(),
a,
];
// update dummy adjacency
self.update_dummy_adj(dummy, boundary2, boundary3);
//self.update_dummy_adj(dummy, boundary2, boundary3);
// replace dummy with new simplex
for i in 0..4 {
......@@ -140,18 +145,12 @@ impl Triangulation {
self.remove_tet(dummy_label);
// internal gluing
self.half_edges.glue_triangles(
a.next().adj_int().next().next(),
b.next().adj_int().next().next(),
);
self.half_edges.glue_triangles(
b.next().next().adj_int().next(),
c.next().next().adj_int().next(),
);
self.half_edges.glue_triangles(
c.next().adj_int().next().next(),
a.next().next().adj_int().next(),
);
self.half_edges
.glue_triangles(a.next().next().adj_int(), b.adj_int().next().adj_int());
self.half_edges
.glue_triangles(b.next().adj_int().next().next(), c.adj_int());
self.half_edges
.glue_triangles(c, a.next().adj_int().next().next());
}
fn move_32(&mut self, label: Label<HalfEdge>) {
......@@ -299,23 +298,23 @@ impl Triangulation {
self.half_edges.set_vertices(a, [v1, v2, v0, v3]);
self.half_edges.set_vertices(b, [v3, v2, v4, v1]); */
}
fn update_dummy_adj(
&mut self,
dummy: [Label<HalfEdge>; 4],
old: [Label<HalfEdge>; 4],
new: [Label<HalfEdge>; 4],
) {
for i in 0..4 {
for j in 0..4 {
if dummy[i].adj_ext(&self.half_edges).same_triangle(old[j]) {
self.half_edges[dummy[i]].adj_ext =
Label::<HalfEdge>::from(new[j].value() / 3 * 3 + dummy[i].value() % 3);
}
}
}
}
/*
fn update_dummy_adj(
&mut self,
dummy: [Label<HalfEdge>; 4],
old: [Label<HalfEdge>; 4],
new: [Label<HalfEdge>; 4],
) {
for i in 0..4 {
for j in 0..4 {
if dummy[i].adj_ext(&self.half_edges).same_triangle(old[j]) {
self.half_edges[dummy[i]].adj_ext =
Label::<HalfEdge>::from(new[j].value() / 3 * 3 + dummy[i].value() % 3);
}
}
}
}
*/
/* fn shard_boundary(&self, label: Label<HalfEdge>, shard: Shard) -> Boundary {
let ext = label.adj_ext(&self.half_edges);
let location = if ext.same_triangle(shard.a1) {
......
......@@ -345,9 +345,9 @@ impl Label<HalfEdge> {
self.value() / 12 == other.value() / 12
}
pub fn same_triangle(&self, other: Label<HalfEdge>) -> bool {
/* pub fn same_triangle(&self, other: Label<HalfEdge>) -> bool {
self.value() / 3 == other.value() / 3
}
} */
/*
pub fn rotation(&self, other: Label<HalfEdge>) -> Rotation {
match (self.value() + other.value()) % 3 {
......@@ -498,7 +498,7 @@ mod tests {
print!("{}", triangulation);
// perform a large number of steps and check each iteration
(0..(1_000_000 * model.sweep())).for_each(|_| {
(0..(100_000 * model.sweep())).for_each(|_| {
let step =
triangulation.choose_step(model.weights, &precomputed.shard, &precomputed.stars);
dbg!(step);
......
Supports Markdown
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