Fix many slicer issues

This commit is contained in:
Connor Slade
2024-06-26 16:27:02 -04:00
parent 287d5e9d7d
commit 3bcf83d8fa
5 changed files with 46 additions and 14 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,4 @@
/target
/*output
*.goo
*.goo
*.stl

15
TODO.md Normal file
View File

@@ -0,0 +1,15 @@
# TODO
- [ ] Verify slicer on more models
- [ ] Preprocess mesh to remove self-intersections?
- [ ] Integrate remote send into ui
- [ ] Allow slicing multiple modals at once
- [ ] Fix translation in slicer (its currently moved by pixels not mm)
- [ ] Allow rotating modals
- [ ] Optimize slicer (BVH?)
- [ ] Allow saving / loading projects
- [ ] Allow deleting objects
- [ ] Use instancing both for object mesh storage and rendering
- [ ] Less internal dependence on GOO format
- [ ] Anti-aliasing
- [ ] Cache transformed points

View File

@@ -54,19 +54,22 @@ fn main() -> Result<()> {
let mut buf = String::new();
stdin().read_line(&mut buf).unwrap();
let teapot = Arc::new(fs::read("out.goo")?);
http.add_file("teapot4.goo", teapot.clone());
let teapot = Arc::new(fs::read("fox.goo")?);
http.add_file("fox.goo", teapot.clone());
mqtt.send_command(
&mainboard_id,
UploadFile::new("teapot4.goo".to_owned(), http_port, &teapot),
UploadFile::new("fox.goo".to_owned(), http_port, &teapot),
)
.unwrap();
let mut buf = String::new();
stdin().read_line(&mut buf).unwrap();
mqtt.send_command(
&mainboard_id,
StartPrinting {
filename: "out.goo".to_owned(),
filename: "fox.goo".to_owned(),
start_layer: 0,
},
)

View File

@@ -50,28 +50,37 @@ impl Mesh {
let v1 = self.transform(&self.vertices[face[1] as usize]);
let v2 = self.transform(&self.vertices[face[2] as usize]);
let dot0 = v0.z - height;
let dot1 = v1.z - height;
let dot2 = v2.z - height;
let mut dot0 = v0.z - height;
let mut dot1 = v1.z - height;
let mut dot2 = v2.z - height;
let mut result = Vec::new();
if dot0 == 0.0 || dot1 == 0.0 || dot2 == 0.0 {
dot0 -= 0.0001;
dot1 -= 0.0001;
dot2 -= 0.0001;
}
let mut result = [Pos::zeros(); 2];
let mut index = 0;
if dot0 * dot1 < 0.0 {
let t = dot0 / (dot0 - dot1);
let intersection = v0 + t * (v1 - v0);
result.push(intersection);
result[index] = intersection;
index += 1;
}
if dot1 * dot2 < 0.0 {
let t = dot1 / (dot1 - dot2);
let intersection = v1 + t * (v2 - v1);
result.push(intersection);
result[index] = intersection;
index += 1;
}
if dot2 * dot0 < 0.0 {
let t = dot2 / (dot2 - dot0);
let intersection = v2 + t * (v0 - v2);
result.push(intersection);
result[index] = intersection;
}
result

View File

@@ -79,8 +79,12 @@ pub fn slice_goo(slice_config: &SliceConfig, model: &Mesh, progress: impl Fn(u32
encoder.add_run(start - last, 0);
}
encoder.add_run(end - start, 255);
last = end;
if start > end {
eprintln!("Invalid run {}-{}", start, end);
} else {
encoder.add_run(end - start, 255);
last = end;
}
}
let image_size = slice_config.platform_resolution.x as u64