Skip to content

Commit

Permalink
tests + error-checking for CAD backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom committed Jan 23, 2024
1 parent 206ec3e commit 3e3ec7e
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 84 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ https://github.com/twitchyliquid64/liquid-cad/assets/6328589/70ce6e84-25ff-4af1-
### Backlog for Beta

* More work on Help page
* Fix Y-mirroring for exported files
* Export to STEP
* Arc dragging
* Broken constraint tools / solver stability (need help!):
Expand Down
56 changes: 31 additions & 25 deletions detailer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl<'a> Widget<'a> {
.constrain(true)
.collapsible(false)
.title_bar(false)
.default_height(520.0)
.anchor(egui::Align2::RIGHT_TOP, egui::Vec2::new(-4., 4.));

window.show(ctx, |ui| {
Expand Down Expand Up @@ -987,7 +988,8 @@ impl<'a> Widget<'a> {
.text("Flatten tolerance").suffix("mm").logarithmic(true));

if let Some(err) = self.drawing.last_solve_error {
ui.add(egui::Label::new(format!("⚠ Solver is inconsistent!! avg err: {:.3}mm", err)));
ui.add(egui::Label::new(egui::RichText::new(format!("⚠ Solver is inconsistent!! avg err: {:.3}mm", err))
.color(ui.visuals().warn_fg_color)));
ui.add_space(5.0);
}

Expand Down Expand Up @@ -1098,33 +1100,37 @@ impl<'a> Widget<'a> {
}

if ui.add_enabled(self.drawing.groups.len() > 0, egui::Button::new("STL 📥")).clicked() {
if let Ok(solid) = self.drawing.part_extrude(self.state.extrusion_amt) {
use drawing::l::three_d::*;

export_fn.take().map(|f| f("STL", "stl", solid_to_stl(solid, self.drawing.props.flatten_tolerance)));
} else {
self.toasts.add(egui_toast::Toast {
text: "Export failed!".into(),
kind: egui_toast::ToastKind::Error,
options: egui_toast::ToastOptions::default()
.duration_in_seconds(4.0)
.show_progress(true)
});
match self.drawing.as_solid(self.state.extrusion_amt) {
Ok(solid) => {
use drawing::l::three_d::*;
export_fn.take().map(|f| f("STL", "stl", solid_to_stl(solid, self.drawing.props.flatten_tolerance)));
},
Err(err) => {
self.toasts.add(egui_toast::Toast {
text: format!("Export failed!\n\nErr: {:?}", err).into(),
kind: egui_toast::ToastKind::Error,
options: egui_toast::ToastOptions::default()
.duration_in_seconds(4.0)
.show_progress(true)
});
}
}
}
if ui.add_enabled(self.drawing.groups.len() > 0, egui::Button::new("OBJ 📥")).clicked() {
if let Ok(solid) = self.drawing.part_extrude(self.state.extrusion_amt) {
use drawing::l::three_d::*;

export_fn.take().map(|f| f("OBJ", "obj", solid_to_obj(solid, self.drawing.props.flatten_tolerance)));
} else {
self.toasts.add(egui_toast::Toast {
text: "Export failed!".into(),
kind: egui_toast::ToastKind::Error,
options: egui_toast::ToastOptions::default()
.duration_in_seconds(4.0)
.show_progress(true)
});
match self.drawing.as_solid(self.state.extrusion_amt) {
Ok(solid) => {
use drawing::l::three_d::*;
export_fn.take().map(|f| f("OBJ", "obj", solid_to_obj(solid, self.drawing.props.flatten_tolerance)));
},
Err(err) => {
self.toasts.add(egui_toast::Toast {
text: format!("Export failed!\n\nErr: {:?}", err).into(),
kind: egui_toast::ToastKind::Error,
options: egui_toast::ToastOptions::default()
.duration_in_seconds(4.0)
.show_progress(true)
});
}
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions drawing/src/data/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Group {
}
}

pub fn compute_path(&self, data: &super::Data) -> Result<Vec<kurbo::BezPath>, ()> {
pub fn compute_path(&self, data: &super::Data) -> Vec<kurbo::BezPath> {
// geometry that has been emitted
let mut remaining = self.features.clone();
remaining.reverse();
Expand Down Expand Up @@ -139,7 +139,7 @@ impl Group {
paths.push(current.0);
}

Ok(paths)
paths
}
}

Expand Down
Loading

0 comments on commit 3e3ec7e

Please sign in to comment.