mapbox / wagyu

A general library for geometry operations of union, intersections, difference, and xor
Other
166 stars 33 forks source link

Return early if original polygons don't require fixing #98

Open astojilj opened 5 years ago

astojilj commented 5 years ago

In context of https://github.com/mapbox/mapbox-gl-native/issues/15268: if the original polygons are correct, there is no need to provide result that reorders original and return true. Client then constructs another container, copying and casting all returned to domain specific type... e.g https://github.com/mapbox/mapbox-gl-native/blob/273ad436fb4d2a18c6749bd4e40fa56546e9285c/src/mbgl/tile/geometry_tile_data.cpp#L51

In context of wagyu code, bookkeeping the dirty state would enable return statement after correct_topology:

template <typename T2>
bool execute(clip_type cliptype,
                 mapbox::geometry::multi_polygon<T2>& solution,
                 fill_type subject_fill_type,
                 fill_type clip_fill_type) {

        if (minima_list.empty()) {
            return false;
        }

        ring_manager<T> manager;

        build_hot_pixels(minima_list, manager);

        execute_vatti(minima_list, manager, cliptype, subject_fill_type, clip_fill_type);

        correct_topology(manager);

        build_result(solution, manager, reverse_output);

        return true;
    }