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

support multi-level walls #103

Merged
merged 7 commits into from
Jul 31, 2024
Merged

support multi-level walls #103

merged 7 commits into from
Jul 31, 2024

Conversation

jamesbradleym
Copy link
Contributor

@jamesbradleym jamesbradleym commented Jul 25, 2024

BACKGROUND:

  • Multi-level spaces do not create walls per level, instead the height of the wall is the height of those levels

DESCRIPTION:

  • Splits the walls from pringle by level prior to merging

Addresses: https://github.com/hypar-io/pringle/issues/1290


This change is Reviewable

@jamesbradleym jamesbradleym requested a review from wynged July 25, 2024 13:36
Copy link
Member

@wynged wynged left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r1, all commit messages.
Reviewable status: 1 change requests, 0 of 1 approvals obtained, 5 unresolved discussions (waiting on @jamesbradleym)


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 1 at r1 (raw file):

using DotLiquid.Tags;

what's this for?


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 31 at r1 (raw file):

                }

                levels.Sort((level1, level2) => level1.Elevation.CompareTo(level2.Elevation));

doesn't matter much, but I might make the method below create the ordered list of levels internally rather than requiring that the levels being passed in be sorted. might prevent a mistake at some future date if we mis-order the levels or order them in some other way for some other reason, the SplitWallsByLevels method could just keep working if it did it all internally.


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 60 at r1 (raw file):

        }

        public static List<StandardWall> SplitWallsByLevels(List<StandardWall> walls, List<Level> levels, Random random)

making the walls argument be for IEnumerable<StandardWall> would make you not need to do ToList above.


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 87 at r1 (raw file):

                            var newWall = new StandardWall(
                                wall.CenterLine,
                                0.1,

what is 0.1?


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 103 at r1 (raw file):

                    else
                    {
                        newWalls.Add(wall);

can we reduce the nesting a bit? you can invert some if statements, and do newWalls.Add(wall); return if they are true. flatter code is easier to read/reason about I think. sometimes I think of the first part of a method like "reasons not to do the normal thing" and then "the normal thing" below those checks.

Copy link
Member

@wynged wynged left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r1.
Reviewable status: 1 change requests, 0 of 1 approvals obtained, 5 unresolved discussions (waiting on @jamesbradleym)

Copy link
Contributor Author

@jamesbradleym jamesbradleym left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 change requests, 0 of 1 approvals obtained, 5 unresolved discussions (waiting on @wynged)


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 1 at r1 (raw file):

Previously, wynged (Eric Wassail) wrote…

what's this for?

Removed, not sure what added that.


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 31 at r1 (raw file):

Previously, wynged (Eric Wassail) wrote…

doesn't matter much, but I might make the method below create the ordered list of levels internally rather than requiring that the levels being passed in be sorted. might prevent a mistake at some future date if we mis-order the levels or order them in some other way for some other reason, the SplitWallsByLevels method could just keep working if it did it all internally.

Moved to SplitWallsByLevel


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 60 at r1 (raw file):

Previously, wynged (Eric Wassail) wrote…

making the walls argument be for IEnumerable<StandardWall> would make you not need to do ToList above.

👍🏻


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 87 at r1 (raw file):

Previously, wynged (Eric Wassail) wrote…

what is 0.1?

This was a hard coded wall thickness value. Maybe it would be valuable to also group walls by thickness prior to processing, after all we wouldn't want to merge walls of different thicknesses. Pringle has a set value for all wall thicknesses currently but that would be a reasonable update to make. (updated it to .13335 which is the actual pringle value but I'll see about grouping by thickness and then iterating through those values and reapplying for made walls)


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 103 at r1 (raw file):

Previously, wynged (Eric Wassail) wrote…

can we reduce the nesting a bit? you can invert some if statements, and do newWalls.Add(wall); return if they are true. flatter code is easier to read/reason about I think. sometimes I think of the first part of a method like "reasons not to do the normal thing" and then "the normal thing" below those checks.

Done!

@jamesbradleym jamesbradleym requested a review from wynged July 25, 2024 16:18
Copy link
Member

@wynged wynged left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: 1 change requests, 0 of 1 approvals obtained, 2 unresolved discussions (waiting on @jamesbradleym)


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 87 at r1 (raw file):

Previously, jamesbradleym wrote…

This was a hard coded wall thickness value. Maybe it would be valuable to also group walls by thickness prior to processing, after all we wouldn't want to merge walls of different thicknesses. Pringle has a set value for all wall thicknesses currently but that would be a reasonable update to make. (updated it to .13335 which is the actual pringle value but I'll see about grouping by thickness and then iterating through those values and reapplying for made walls)

yea, I think grouping by thickness makes sense. even right now I think someone could technically end up with two different thicknesses if they changed the units of their project right? if not, mabye this is fine for now.


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 65 at r2 (raw file):

        public static List<StandardWall> SplitWallsByLevels(IEnumerable<StandardWall> walls, List<Level> levels, Random random)
        {
            levels.Sort((level1, level2) => level1.Elevation.CompareTo(level2.Elevation));

I think make a new sortedLevels enumerable rather than sorting the incoming one. sorting this incoming list would qualify as a side effect which isn't normally desirable unless done for a specific reason.

Copy link
Contributor Author

@jamesbradleym jamesbradleym left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 change requests, 0 of 1 approvals obtained, 2 unresolved discussions (waiting on @wynged)


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 87 at r1 (raw file):

Previously, wynged (Eric Wassail) wrote…

yea, I think grouping by thickness makes sense. even right now I think someone could technically end up with two different thicknesses if they changed the units of their project right? if not, mabye this is fine for now.

Yep, I think that's possible. We're using wallThickness: 0.135, in defaultValuesMetric and 5.25" in defaultValuesImperial (0.13335m). The group by thickness change would resolve this discrepancy (keeping these walls from merging, maybe we want a fuzziness/tolerance here as well..)


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 65 at r2 (raw file):

Previously, wynged (Eric Wassail) wrote…

I think make a new sortedLevels enumerable rather than sorting the incoming one. sorting this incoming list would qualify as a side effect which isn't normally desirable unless done for a specific reason.

gotcha, misunderstood - made a new list from ordered levels

Copy link
Member

@wynged wynged left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 1 change requests, 0 of 1 approvals obtained, all discussions resolved


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 87 at r1 (raw file):

Previously, jamesbradleym wrote…

Yep, I think that's possible. We're using wallThickness: 0.135, in defaultValuesMetric and 5.25" in defaultValuesImperial (0.13335m). The group by thickness change would resolve this discrepancy (keeping these walls from merging, maybe we want a fuzziness/tolerance here as well..)

yea, let's give a tolerance, let's say 1mm I think, that's bigger than just a numeric EPSILON but seems quite reasonable for walls. Your call if you want to do this now though. we don't actualy let users change their wall thickness, so we could deal later if we wanted.

Copy link
Member

@wynged wynged left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained, all discussions resolved

Copy link
Contributor Author

@jamesbradleym jamesbradleym left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 of 1 approvals obtained, all discussions resolved


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 87 at r1 (raw file):

Previously, wynged (Eric Wassail) wrote…

yea, let's give a tolerance, let's say 1mm I think, that's bigger than just a numeric EPSILON but seems quite reasonable for walls. Your call if you want to do this now though. we don't actualy let users change their wall thickness, so we could deal later if we wanted.

Wouldn't mind getting your thoughts on the tolerance grouping.

It forces everything to check equality with tolerance rather than the hash which moves it to O(n) rather than the hash O(1) but given how quick Math.Abs(x - y) <= _tolerance; is that seems fine?

Copy link
Contributor Author

@jamesbradleym jamesbradleym left a comment

Choose a reason for hiding this comment

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

per conversation with Eric & Kat -

Updated to migrate values from/to default metric to/from default imperial based on Project Settings unit system

Reviewable status: :shipit: complete! 1 of 1 approvals obtained, all discussions resolved

@jamesbradleym jamesbradleym requested a review from wynged July 30, 2024 22:04
Copy link
Member

@wynged wynged left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: 1 change requests, 0 of 1 approvals obtained, 2 unresolved discussions (waiting on @jamesbradleym)


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 87 at r1 (raw file):

Previously, jamesbradleym wrote…

Wouldn't mind getting your thoughts on the tolerance grouping.

It forces everything to check equality with tolerance rather than the hash which moves it to O(n) rather than the hash O(1) but given how quick Math.Abs(x - y) <= _tolerance; is that seems fine?

seems ok, there will be issues with kind of bucketing, but the unit system approach should help us do more reasonable things in the future.


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 24 at r5 (raw file):

            if (inputModels.TryGetValue("Project Settings", out var settingsModel))
            {
                foreach (var elementDict in settingsModel.Elements)

we should probably find the single element by discriminator rather than looking at all elements.


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 39 at r5 (raw file):

            {
                var walls = wallsModel.AllElementsOfType<StandardWall>();
                if (unitSystem != null)

can unit system ever equal null, you set i to metric above.

Copy link
Contributor Author

@jamesbradleym jamesbradleym left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 change requests, 0 of 1 approvals obtained, 2 unresolved discussions (waiting on @wynged)


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 24 at r5 (raw file):

Previously, wynged (Eric Wassail) wrote…

we should probably find the single element by discriminator rather than looking at all elements.

Gotcha, changed to find the first element with ["discriminator"] = Elements.ProjectSettings


LayoutFunctions/WallsLOD200/src/WallsLOD200.cs line 39 at r5 (raw file):

Previously, wynged (Eric Wassail) wrote…

can unit system ever equal null, you set i to metric above.

The unitSystem from the model is coming back as a string?, so this is a safety check, moved it to the moment of setting rather than here.

@jamesbradleym jamesbradleym requested a review from wynged July 31, 2024 15:18
Copy link
Member

@wynged wynged left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r6, all commit messages.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained, all discussions resolved

@jamesbradleym jamesbradleym merged commit 26bbacf into master Jul 31, 2024
1 check passed
@jamesbradleym jamesbradleym deleted the multi-level-walls branch July 31, 2024 15:22
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