Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FetchContent_MakeAvailable(optimizationtools)
FetchContent_Declare(
shape
GIT_REPOSITORY https://github.com/fontanf/shape.git
GIT_TAG 333bea2942ab297cd067add1bb6e1bbb333dcd75
GIT_TAG d062b436349b12c659ca1c5b6718ec0e9c5da7a2
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../shape/"
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(shape)
Expand Down
29 changes: 22 additions & 7 deletions src/irregular/branching_scheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ BranchingScheme::BranchingScheme(
BranchingSchemeBinType& bb_bin_type = direction_data.bin_types[bin_type_id];
Shape shape = convert_shape(bin_type.shape_scaled, direction);

shape = shape::clean_extreme_slopes(shape, false);

auto mm = shape.compute_min_max();
bb_bin_type.x_min = mm.first.x;
bb_bin_type.x_max = mm.second.x;
Expand Down Expand Up @@ -155,7 +157,9 @@ BranchingScheme::BranchingScheme(
border_pos < (DefectId)simplified_bin_type.borders.size();
++border_pos) {
const Shape& simplified_inflated_shape = simplified_bin_type.borders[border_pos].shape_inflated;
const Shape& shape_inflated = convert_shape(simplified_inflated_shape, direction);
Shape shape_inflated = convert_shape(simplified_inflated_shape, direction);

shape_inflated = shape::clean_extreme_slopes(shape_inflated, true);

// Supports.
shape::ShapeSupports supports = shape::compute_shape_supports(shape_inflated, false);
Expand Down Expand Up @@ -185,7 +189,9 @@ BranchingScheme::BranchingScheme(
++defect_id) {
//std::cout << "defect_id " << defect_id << std::endl;
const Shape& simplified_inflated_shape = simplified_bin_type.defects[defect_id].shape_inflated;
const Shape& shape_inflated = convert_shape(simplified_inflated_shape, direction);
Shape shape_inflated = convert_shape(simplified_inflated_shape, direction);

shape_inflated = shape::clean_extreme_slopes(shape_inflated, true);

// Supports.
shape::ShapeSupports supports = shape::compute_shape_supports(shape_inflated, false);
Expand All @@ -204,7 +210,9 @@ BranchingScheme::BranchingScheme(
hole_pos < (ShapePos)simplified_bin_type.defects[defect_id].holes_deflated.size();
++hole_pos) {
const Shape& simplified_deflated_shape = simplified_bin_type.defects[defect_id].holes_deflated[hole_pos];
const Shape& shape_deflated = convert_shape(simplified_deflated_shape, direction);
Shape shape_deflated = convert_shape(simplified_deflated_shape, direction);

shape_deflated = shape::clean_extreme_slopes(shape_deflated, false);

// Update trapezoidation input.
holes_deflated.push_back(shape_deflated);
Expand Down Expand Up @@ -286,8 +294,11 @@ BranchingScheme::BranchingScheme(
+ "_inflated_simplified.svg");
}

const Shape& shape = convert_shape(simplified_shape, angle_range.first, mirror, direction);
const Shape& shape_inflated = convert_shape(simplified_inflated_shape, angle_range.first, mirror, direction);
Shape shape = convert_shape(simplified_shape, angle_range.first, mirror, direction);
Shape shape_inflated = convert_shape(simplified_inflated_shape, angle_range.first, mirror, direction);

shape = shape::clean_extreme_slopes(shape, true);
shape_inflated = shape::clean_extreme_slopes(shape_inflated, true);

if (write_shapes) {
simplified_inflated_shape.write_svg(
Expand Down Expand Up @@ -332,7 +343,9 @@ BranchingScheme::BranchingScheme(
++hole_pos) {
const Shape& simplified_shape = simplified_item_type.shapes[item_shape_pos].holes[hole_pos];

const Shape& shape = convert_shape(simplified_shape, angle_range.first, mirror, direction);
Shape shape = convert_shape(simplified_shape, angle_range.first, mirror, direction);

shape = shape::clean_extreme_slopes(shape, false);

// Update trapezoidation input.
holes.push_back(shape);
Expand All @@ -358,7 +371,9 @@ BranchingScheme::BranchingScheme(
++hole_pos) {
const Shape& simplified_deflated_shape = simplified_item_type.shapes[item_shape_pos].holes_deflated[hole_pos];

const Shape& shape_deflated = convert_shape(simplified_deflated_shape, angle_range.first, mirror, direction);
Shape shape_deflated = convert_shape(simplified_deflated_shape, angle_range.first, mirror, direction);

shape_deflated = shape::clean_extreme_slopes(shape_deflated, false);

// Update trapezoidation input.
holes_deflated.push_back(shape_deflated);
Expand Down
24 changes: 2 additions & 22 deletions src/irregular/instance_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,17 +441,7 @@ std::pair<Shape, std::vector<Shape>> process_shape_outer(
{
bool outer = true;
Shape shape_tmp = shape::approximate_by_line_segments(shape, 1, outer);
for (int i = 0;; ++i) {
if (i == 100) {
throw std::runtime_error(
"packingsolver::irregular::process_shape_outer: "
"too many iterations.");
}
auto res = shape::clean_extreme_slopes(shape_tmp, outer);
if (!res.first)
break;
shape_tmp = res.second;
}
shape_tmp = shape::clean_extreme_slopes(shape_tmp, outer);
return shape::remove_self_intersections(shape_tmp);
}

Expand All @@ -460,17 +450,7 @@ std::vector<Shape> process_shape_inner(
{
bool outer = false;
Shape shape_tmp = shape::approximate_by_line_segments(shape, 1, outer);
for (int i = 0;; ++i) {
if (i == 100) {
throw std::runtime_error(
"packingsolver::irregular::process_shape_inner: "
"too many iterations.");
}
auto res = shape::clean_extreme_slopes(shape_tmp, outer);
if (!res.first)
break;
shape_tmp = res.second;
}
shape_tmp = shape::clean_extreme_slopes(shape_tmp, outer);
return shape::extract_all_holes_from_self_intersecting_hole(shape_tmp);
}

Expand Down
Loading