@@ -100,6 +100,8 @@ BranchingScheme::BranchingScheme(
100100 BranchingSchemeBinType& bb_bin_type = direction_data.bin_types [bin_type_id];
101101 Shape shape = convert_shape (bin_type.shape_scaled , direction);
102102
103+ shape = shape::clean_extreme_slopes (shape, false );
104+
103105 auto mm = shape.compute_min_max ();
104106 bb_bin_type.x_min = mm.first .x ;
105107 bb_bin_type.x_max = mm.second .x ;
@@ -155,7 +157,9 @@ BranchingScheme::BranchingScheme(
155157 border_pos < (DefectId)simplified_bin_type.borders .size ();
156158 ++border_pos) {
157159 const Shape& simplified_inflated_shape = simplified_bin_type.borders [border_pos].shape_inflated ;
158- const Shape& shape_inflated = convert_shape (simplified_inflated_shape, direction);
160+ Shape shape_inflated = convert_shape (simplified_inflated_shape, direction);
161+
162+ shape_inflated = shape::clean_extreme_slopes (shape_inflated, true );
159163
160164 // Supports.
161165 shape::ShapeSupports supports = shape::compute_shape_supports (shape_inflated, false );
@@ -185,7 +189,9 @@ BranchingScheme::BranchingScheme(
185189 ++defect_id) {
186190 // std::cout << "defect_id " << defect_id << std::endl;
187191 const Shape& simplified_inflated_shape = simplified_bin_type.defects [defect_id].shape_inflated ;
188- const Shape& shape_inflated = convert_shape (simplified_inflated_shape, direction);
192+ Shape shape_inflated = convert_shape (simplified_inflated_shape, direction);
193+
194+ shape_inflated = shape::clean_extreme_slopes (shape_inflated, true );
189195
190196 // Supports.
191197 shape::ShapeSupports supports = shape::compute_shape_supports (shape_inflated, false );
@@ -204,7 +210,9 @@ BranchingScheme::BranchingScheme(
204210 hole_pos < (ShapePos)simplified_bin_type.defects [defect_id].holes_deflated .size ();
205211 ++hole_pos) {
206212 const Shape& simplified_deflated_shape = simplified_bin_type.defects [defect_id].holes_deflated [hole_pos];
207- const Shape& shape_deflated = convert_shape (simplified_deflated_shape, direction);
213+ Shape shape_deflated = convert_shape (simplified_deflated_shape, direction);
214+
215+ shape_deflated = shape::clean_extreme_slopes (shape_deflated, false );
208216
209217 // Update trapezoidation input.
210218 holes_deflated.push_back (shape_deflated);
@@ -286,8 +294,11 @@ BranchingScheme::BranchingScheme(
286294 + " _inflated_simplified.svg" );
287295 }
288296
289- const Shape& shape = convert_shape (simplified_shape, angle_range.first , mirror, direction);
290- const Shape& shape_inflated = convert_shape (simplified_inflated_shape, angle_range.first , mirror, direction);
297+ Shape shape = convert_shape (simplified_shape, angle_range.first , mirror, direction);
298+ Shape shape_inflated = convert_shape (simplified_inflated_shape, angle_range.first , mirror, direction);
299+
300+ shape = shape::clean_extreme_slopes (shape, true );
301+ shape_inflated = shape::clean_extreme_slopes (shape_inflated, true );
291302
292303 if (write_shapes) {
293304 simplified_inflated_shape.write_svg (
@@ -332,7 +343,9 @@ BranchingScheme::BranchingScheme(
332343 ++hole_pos) {
333344 const Shape& simplified_shape = simplified_item_type.shapes [item_shape_pos].holes [hole_pos];
334345
335- const Shape& shape = convert_shape (simplified_shape, angle_range.first , mirror, direction);
346+ Shape shape = convert_shape (simplified_shape, angle_range.first , mirror, direction);
347+
348+ shape = shape::clean_extreme_slopes (shape, false );
336349
337350 // Update trapezoidation input.
338351 holes.push_back (shape);
@@ -358,7 +371,9 @@ BranchingScheme::BranchingScheme(
358371 ++hole_pos) {
359372 const Shape& simplified_deflated_shape = simplified_item_type.shapes [item_shape_pos].holes_deflated [hole_pos];
360373
361- const Shape& shape_deflated = convert_shape (simplified_deflated_shape, angle_range.first , mirror, direction);
374+ Shape shape_deflated = convert_shape (simplified_deflated_shape, angle_range.first , mirror, direction);
375+
376+ shape_deflated = shape::clean_extreme_slopes (shape_deflated, false );
362377
363378 // Update trapezoidation input.
364379 holes_deflated.push_back (shape_deflated);
0 commit comments