Skip to content

Commit 85ed8b8

Browse files
committed
Add recursion bound
1 parent b19ec45 commit 85ed8b8

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

libraries/path-bool/src/intersection_path_segment.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,33 @@ pub fn path_segment_intersection(seg0: &PathSegment, seg1: &PathSegment, endpoin
116116
let mut subdivided0 = Vec::new();
117117
let mut subdivided1 = Vec::new();
118118

119+
// check if start and end points are on the other bezier curves. If so, add as intersection.
120+
119121
while !pairs.is_empty() {
120122
next_pairs.clear();
121-
dbg!("checking pairs");
123+
// dbg!("checking pairs");
124+
125+
if pairs.len() > 1000 {
126+
return vec![];
127+
}
122128

123129
for (seg0, seg1) in pairs.iter() {
124130
if segments_equal(&seg0.seg, &seg1.seg, eps.point) {
125131
// TODO: move this outside of this loop?
126132
continue; // TODO: what to do?
127133
}
128134

129-
let is_linear0 = bounding_box_max_extent(&seg0.bounding_box) <= eps.linear || (seg1.end_param - seg1.start_param).abs() < eps.param;
135+
let diff1 = (seg0.start_param - seg0.end_param).abs();
136+
let diff2 = (seg1.start_param - seg1.end_param).abs();
137+
// dbg!(diff1.min(diff2));
138+
let is_linear0 = bounding_box_max_extent(&seg0.bounding_box) <= eps.linear || (seg0.end_param - seg0.start_param).abs() < eps.param;
130139
let is_linear1 = bounding_box_max_extent(&seg1.bounding_box) <= eps.linear || (seg1.end_param - seg1.start_param).abs() < eps.param;
131140

132141
if is_linear0 && is_linear1 {
133142
let line_segment0 = path_segment_to_line_segment(&seg0.seg);
134143
let line_segment1 = path_segment_to_line_segment(&seg1.seg);
135144
if let Some(st) = line_segment_intersection(line_segment0, line_segment1, eps.param) {
136-
dbg!("pushing param");
145+
// dbg!("pushing param");
137146
params.push([lerp(seg0.start_param, seg0.end_param, st.0), lerp(seg1.start_param, seg1.end_param, st.1)]);
138147
}
139148
} else {

libraries/path-bool/src/path_boolean.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,6 @@ pub enum BooleanError {
13131313
}
13141314

13151315
pub fn path_boolean(a: &Path, a_fill_rule: FillRule, b: &Path, b_fill_rule: FillRule, op: PathBooleanOperation) -> Result<Vec<Path>, BooleanError> {
1316-
eprintln!("converting to edges");
13171316
let mut unsplit_edges: Vec<MajorGraphEdgeStage1> = a.iter().map(segment_to_edge(1)).chain(b.iter().map(segment_to_edge(2))).flatten().collect();
13181317

13191318
split_at_self_intersections(&mut unsplit_edges);

0 commit comments

Comments
 (0)