void Region::boolean_operation(int op, Region& dst, const Region& lhs, const Rect& rhs, int dx, int dy) { if (!rhs.isValid()) { LOGE("Region::boolean_operation(op=%d) invalid Rect={%d,%d,%d,%d}", op, rhs.left, rhs.top, rhs.right, rhs.bottom); return; } #if VALIDATE_WITH_CORECG || VALIDATE_REGIONS boolean_operation(op, dst, lhs, Region(rhs), dx, dy); #else size_t lhs_count; Rect const * const lhs_rects = lhs.getArray(&lhs_count); region_operator<Rect>::region lhs_region(lhs_rects, lhs_count); region_operator<Rect>::region rhs_region(&rhs, 1, dx, dy); region_operator<Rect> operation(op, lhs_region, rhs_region); { // scope for rasterizer (dtor has side effects) rasterizer r(dst); operation(r); } #endif }
void Region::boolean_operation(int op, Region& dst, const Region& lhs, const Rect& rhs) { boolean_operation(op, dst, lhs, rhs, 0, 0); }
const Region Region::operation(const Region& rhs, int dx, int dy, int op) const { Region result; boolean_operation(op, result, *this, rhs, dx, dy); return result; }
const Region Region::operation(const Rect& rhs, int op) const { Region result; boolean_operation(op, result, *this, rhs); return result; }
Region& Region::operationSelf(const Region& rhs, int dx, int dy, int op) { Region lhs(*this); boolean_operation(op, *this, lhs, rhs, dx, dy); return *this; }
Region& Region::operationSelf(const Rect& r, int op) { Region lhs(*this); boolean_operation(op, *this, lhs, r); return *this; }
void Polyhedron_demo_nef_plugin::on_actionMinkowskiSum_triggered() { boolean_operation(MINKOWSKI_SUM); }
void Polyhedron_demo_nef_plugin::on_actionDifference_triggered() { boolean_operation(BOOLEAN_DIFFERENCE); }
void Polyhedron_demo_nef_plugin::on_actionIntersection_triggered() { boolean_operation(BOOLEAN_INTERSECTION); }
void Polyhedron_demo_nef_plugin::on_actionUnion_triggered() { boolean_operation(BOOLEAN_UNION); }