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
12 changes: 10 additions & 2 deletions src/clean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,11 +681,13 @@ Shape clean_extreme_slopes_outer_2(
const Shape& shape_orig,
std::vector<Shape>& triangles_added)
{
#ifdef CLEAN_ENABLE_DEBUG
if (!shape_orig.check()) {
throw std::invalid_argument(
FUNC_SIGNATURE + ": "
"invalid input shape.");
}
#endif

Shape shape = shape_orig;
ElementPos element_prev_pos = shape.elements.size() - 1;
Expand Down Expand Up @@ -901,11 +903,13 @@ Shape clean_extreme_slopes_inner_2(
ShapeWithHoles shape::clean_extreme_slopes_outer(
const Shape& shape_orig)
{
#ifdef CLEAN_ENABLE_DEBUG
if (!shape_orig.check()) {
//write_json({{shape_orig}}, {}, "clean_extreme_slopes_outer_input.json");
throw std::invalid_argument(
FUNC_SIGNATURE + ": invalid input shape.");
}
#endif

Shape shape = shape_orig;
std::vector<Shape> triangles_added;
Expand Down Expand Up @@ -940,22 +944,26 @@ ShapeWithHoles shape::clean_extreme_slopes_outer(
return u.front();
}

#ifdef CLEAN_ENABLE_DEBUG
if (!shape.check()) {
throw std::invalid_argument(
FUNC_SIGNATURE + ": "
"invalid shape after extreme slopes cleaning.");
}
#endif

return {shape};
}

std::vector<Shape> shape::clean_extreme_slopes_inner(
const Shape& shape_orig)
{
#ifdef CLEAN_ENABLE_DEBUG
if (!shape_orig.check()) {
throw std::invalid_argument(
FUNC_SIGNATURE + ": invalid input shape.");
}
#endif

Shape shape = shape_orig;
std::vector<Shape> triangles_removed;
Expand Down Expand Up @@ -996,18 +1004,18 @@ std::vector<Shape> shape::clean_extreme_slopes_inner(
return output;
}

if (!shape.check()) {
#ifdef CLEAN_ENABLE_DEBUG
if (!shape.check()) {
Writer().add_shape(shape_orig).add_shape(shape).write_json("tmp.json");
std::ofstream file{"clean_extreme_slopes_inner_inputs.json"};
nlohmann::json json;
json["shape"] = shape_orig.to_json();
file << std::setw(4) << json << std::endl;
#endif
throw std::invalid_argument(
FUNC_SIGNATURE + ": "
"invalid shape after extreme slopes cleaning.");
}
#endif

return {shape};
}
Expand Down
6 changes: 6 additions & 0 deletions src/simplification.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//#define SIMPLIFICATION_ENABLE_DEBUG

#include "shape/simplification.hpp"

#include "shape/clean.hpp"
Expand Down Expand Up @@ -738,6 +740,7 @@ std::vector<ShapeWithHoles> shape::simplify(
}
}
}
#ifdef SIMPLIFICATION_ENABLE_DEBUG
if (!shape.shape.shape.check()) {
throw std::invalid_argument(
FUNC_SIGNATURE + ": "
Expand All @@ -756,6 +759,7 @@ std::vector<ShapeWithHoles> shape::simplify(
"hole_pos: " + std::to_string(hole_pos) + ".");
}
}
#endif
}

// Build element_keys, approximated_bin_types, approximated_item_types.
Expand Down Expand Up @@ -983,6 +987,7 @@ std::vector<ShapeWithHoles> shape::simplify(
shapes_new[shape_pos] = compute_union(union_inputs[shape_pos]).shapes_with_holes.front();
}

#ifdef SIMPLIFICATION_ENABLE_DEBUG
// Check output.
for (ShapePos shape_pos = 0;
shape_pos < (ShapePos)shapes.size();
Expand All @@ -1007,6 +1012,7 @@ std::vector<ShapeWithHoles> shape::simplify(
}
}
}
#endif

//std::cout << "shape_simplification end" << std::endl;
return shapes_new;
Expand Down
4 changes: 4 additions & 0 deletions src/trapezoidation.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//#define TRAPEZOIDATION_ENABLE_DEBUG

#include "shape/trapezoidation.hpp"

#include "shape/writer.hpp"
Expand Down Expand Up @@ -170,11 +172,13 @@ std::pair<ElementPos, ElementPos> find_trapezoid_containing_vertex(
std::vector<GeneralizedTrapezoid> shape::trapezoidation(
const ShapeWithHoles& shape_orig)
{
#ifdef TRAPEZOIDATION_ENABLE_DEBUG
if (!shape_orig.check()) {
throw std::invalid_argument(
FUNC_SIGNATURE + ": "
"invalid input shape.");
}
#endif
if (!shape_orig.is_polygon()) {
throw std::invalid_argument(
FUNC_SIGNATURE + ": "
Expand Down
Loading