Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed cropping polygon in some corner cases #3184

Merged
merged 2 commits into from
May 13, 2021
Merged

Conversation

bsekachev
Copy link
Member

@bsekachev bsekachev commented May 12, 2021

Motivation and context

Resolved #3178

Hi @dvkruchinin
A test for this case would be good.

How has this been tested?

Manual testing

Checklist

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below)
# Copyright (C) 2021 Intel Corporation
#
# SPDX-License-Identifier: MIT

Comment on lines +153 to +154
(p1.x === p2.x || Math.sign(resultPoints[0] - resultPoints[2]) !== Math.sign(p1.x - p2.x))
&& (p1.y === p2.y || Math.sign(resultPoints[1] - resultPoints[3]) !== Math.sign(p1.y - p2.y))
Copy link
Member Author

@bsekachev bsekachev May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@azhavoro @ActiveChooN

The core change to fix (others are to satisfy eslint, minor refactoring, and some minor bug fixes).

As I understand the issue was following:
After the first (Horizontal) crop p1.x in a corner case could be equal to p2.x).
The same if we reverse crop order (first is Vertical), then p1.y in a corner case could be equal to p2.y.

In these corner cases the condition is false and we do not reverse points when it is actually necessary.

@bsekachev bsekachev changed the title Fixed issue #3178 Fixed cropping polygon in some corner cases May 12, 2021
@bsekachev bsekachev requested a review from nmanovic as a code owner May 12, 2021 16:14
@dvkruchinin
Copy link
Contributor

A test for this case would be good.

Sure. A test will be prepared.

Comment on lines +248 to +249
const dx = offsetCoords[0] ** 2;
const dy = offsetCoords[1] ** 2;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflict between prettier and eslint.
There were suggestion to split to several lines:
https://github.com/prettier/eslint-config-prettier#no-mixed-operators

cvat-canvas/src/typescript/drawHandler.ts Show resolved Hide resolved
Copy link
Contributor

@ActiveChooN ActiveChooN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bsekachev bsekachev merged commit da9b0da into develop May 13, 2021
@nmanovic nmanovic deleted the bs/fixed_issue_3178 branch May 14, 2021 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Polygon cropping bug
4 participants