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

Recoded markup_space to be a recursive function #16

Merged
merged 3 commits into from
Apr 22, 2021

Conversation

supersonic1999
Copy link
Contributor

@supersonic1999 supersonic1999 commented Apr 21, 2021

#15

@psolin
Copy link
Owner

psolin commented Apr 21, 2021

I am getting:

{
    "markups": [
        {
            "Spaces": "Level 3-Area B-Room 302-Sub Room"
        },
        {
            "Spaces": "Level 3-Area B-Room 302-Sub Room"
        },
        {
            "Spaces": "Level 3-Area B-Room 302-Sub Room"
        },
        {
            "Spaces": "Level 3-Area B-Room 302-Sub Room"
        },
        {
            "Spaces": "Level 3-Area B-Room 302-Sub Room"
        },
        {
            "Spaces": "Level 3-Area B-Room 302-Sub Room"
        },
        {
            "Spaces": "Level 3-Area B-Room 302-Sub Room"
        },
        {
            "Spaces": "Level 3-Area B-Room 302-Sub Room"
        },
        {
            "Spaces": "Level 4-Area A-Hallway 2"
        },
        {
            "Spaces": "Level 4-Area A-Hallway 2"
        },
        {
            "Spaces": "Level 4-Area A-Hallway 2"
        },
        {
            "Spaces": "Level 4-Area A-Hallway 2"
        },
        {
            "Spaces": "Level 4-Area A-Hallway 2"
        }
    ]
}

Where it should look like:
Level 3-Area B-Room 305-Sub Room 2
Level 3-Area B-Room 304
Level 3-Area B
Level 3-Area B-Hallway 330
Level 3-Area B-Room 106
Level 3-Area B-Room 302
Level 3-Area B-Room 302-Sub Room
Level 3-Area B-Room 303
Level 4-Area A-Room 401
Level 4-Area A
Level 4-Area A-Hallway 2

@supersonic1999
Copy link
Contributor Author

The original code outputted the same result. Guessing it was bugged or something

@supersonic1999
Copy link
Contributor Author

Ive pushed a commit that allows spaces() to search the tree recursively.
In relation to markup() im pretty stumped on that but the function is now recursive also. As i said in my last comment, the output is the same as it was before i committed, it just doesn't reach the desired output.

@psolin
Copy link
Owner

psolin commented Apr 21, 2021

Spaces looks and works great - thanks for doing that. I'll take a look again at markup_spaces() and see what I can do. I think I was getting closer before.

@psolin
Copy link
Owner

psolin commented Apr 22, 2021

I was afraid of this happening, but I think that I figured it out a long while ago.

In markup_space():
Instead of going into markup.P to find information which just seems to be an endless loop, you'd have to go into markup.Vertices and record those values. Every two sets of numbers in the array are an x,y coordinate. Similarly, there's markup.Rect which only contains two points. I'm not sure which is the best one to use.

For poly lines, it's going to be every control point in the line, but you get the picture. You have to see if all of the points lie inside of a given space. If it falls entirely in one, all points, it is considered to be in that space. If one of the points are outside, it is considered to be out of that space (this is how Revu works anyway).

In get_all_spaces():
You'd also have to pull every object in page.BSISpaces.Path, which seems to be an array with two objects making a point. This is the bounding box of the space that we have to compare each object against.

I think we can do a comparison in this way:
https://stackoverflow.com/questions/55840924/how-to-judge-if-a-polygon-is-inside-another-polygon-in-python

Let me know if you'd be up to the challenge of testing this.

@psolin
Copy link
Owner

psolin commented Apr 22, 2021

I am going to merge this pull request since it does work the way that it did before, and re-post my thoughts in an issue as a bug.

@psolin psolin merged commit dde5f17 into psolin:main Apr 22, 2021
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.

2 participants