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

Geometry_Enigne: Full refactor of polyline offset #3394

Merged
merged 49 commits into from
Oct 17, 2024

Conversation

IsakNaslundBh
Copy link
Contributor

@IsakNaslundBh IsakNaslundBh commented Aug 8, 2024

NOTE: Depends on

BHoM/BHoM#1632

Issues addressed by this PR

Closes #3235
also should resolve all issues for polylines in #1333. Leaving that issue open though, as PolyCurves are not handled by this PR.

Full refactor of Polyline offset.

  • Addition of MultiOffset method that is able to generate a series of offsets for a single curve
  • Make Polyline offset call this new more powerful method
  • Significant amount of edgecases handled
  • Several optimisations put in place by caching of data, stored into new internal classes stored in the objects folder
  • Complete change to methodology for figuring out locations of new nodes etc.

Test files

On SharePoint

Changelog

Additional comments

Started this off as a little side project, that ended up as a quite massive PR, as I went through and thought of more and more edge cases to be handled. Think this now, thoguh, should be really quite stable as well as quick and able to handle many many weird and wonderful edge cases.

The main offset method could for some cases return ever so slightly different results compared to before, but I am pretty confident that what it doing now is more sane and reliable, and gives better control over the behaviour.

Logic I have put in place (by default) is for the offset curve once a self-intersection occurs, is to keep the part with largest area for a closed curve, and always keep the start and end bits for an open curve. Could ofc be changed to longest length or something like that instead, but area, and start and end felt the most sensible to me. as a starting point.

A lot of the code gets a wee bit complex in places, and there is quite a lot of vector maths going on that I have tried to comment as much as possible. Happy to have a chat through it though.

IsakNaslundBh and others added 30 commits May 30, 2024 13:56
… of adjecent parallel segments to its own method and remove method with multiple lists
…ion attribute

Also some additional descriptions
Method growing in complexity, and wanting to enable more powerful features leads to better to migrate the method out to separate method, and for the Offset method to call this method instead.
First gets out the distance to the segment planes, then order by distance, then sort based on required offset, then check until a segment that is actually intersected is found
@IsakNaslundBh
Copy link
Contributor Author

@BHoMBot check compliance

Copy link

bhombot-ci bot commented Oct 14, 2024

@IsakNaslundBh to confirm, the following actions are now queued:

  • check code-compliance
  • check documentation-compliance
  • check project-compliance
  • check branch-compliance
  • check dataset-compliance
  • check copyright-compliance

There are 51 requests in the queue ahead of you.

@IsakNaslundBh
Copy link
Contributor Author

After chat with @pawelbaran have fixed the comments and agreed on the following:

  • Revert back the method signature to what it was before, and only use the OffsetOptions for the MultiOffset method
  • Kept the return type for the main Offset method as a single curve. For multi curve return the MultiOffset method is to be used. Can be discussed if the return type should be changed, but that requires alignment with the POlyCurve offset method as well alignment with methods calling this method.

Copy link
Member

@pawelbaran pawelbaran left a comment

Choose a reason for hiding this comment

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

Happy with the overall code now, just a few little tweaks suggested 👍

Geometry_Engine/Modify/Offset.cs Outdated Show resolved Hide resolved
Geometry_Engine/Modify/Offset.cs Outdated Show resolved Hide resolved
Geometry_Engine/Modify/Offset.cs Outdated Show resolved Hide resolved
Geometry_Engine/Modify/Offset.cs Outdated Show resolved Hide resolved
Geometry_Engine/Modify/Offset.cs Outdated Show resolved Hide resolved
Geometry_Engine/Modify/Offset.cs Outdated Show resolved Hide resolved
Geometry_Engine/Modify/Offset.cs Outdated Show resolved Hide resolved
Geometry_Engine/Modify/Offset.cs Show resolved Hide resolved
@IsakNaslundBh
Copy link
Contributor Author

@BHoMBot check compliance

Copy link

bhombot-ci bot commented Oct 15, 2024

@IsakNaslundBh to confirm, the following actions are now queued:

  • check code-compliance
  • check documentation-compliance
  • check project-compliance
  • check branch-compliance
  • check dataset-compliance
  • check copyright-compliance

Copy link
Member

@pawelbaran pawelbaran left a comment

Choose a reason for hiding this comment

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

I have gone through the code again and explored the test script - all looks good, I think the PR is ready to merge from the code perspective 👍

@IsakNaslundBh what do you think about adding UTs based on the test script you provided? That would be a cherry on top

@IsakNaslundBh
Copy link
Contributor Author

@BHoMBot check unit-tests

Copy link

bhombot-ci bot commented Oct 17, 2024

@IsakNaslundBh to confirm, the following actions are now queued:

  • check unit-tests

@IsakNaslundBh
Copy link
Contributor Author

@BHoMBot check compliance
@BHoMBot check unit-tests
@BHoMBot check required

Copy link

bhombot-ci bot commented Oct 17, 2024

@IsakNaslundBh to confirm, the following actions are now queued:

  • check code-compliance
  • check documentation-compliance
  • check project-compliance
  • check branch-compliance
  • check dataset-compliance
  • check copyright-compliance
  • check unit-tests
  • check code-compliance
  • check documentation-compliance
  • check project-compliance
  • check core
  • check null-handling
  • check serialisation
  • check versioning
  • check installer

Copy link

bhombot-ci bot commented Oct 17, 2024

The check code-compliance has already been run previously and recorded as a successful check. This check has not been run again at this time.

Copy link

bhombot-ci bot commented Oct 17, 2024

The check documentation-compliance has already been run previously and recorded as a successful check. This check has not been run again at this time.

Copy link
Member

@pawelbaran pawelbaran left a comment

Choose a reason for hiding this comment

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

Happy to finally approve, thank you @IsakNaslundBh for this intellectual adventure! 😃

@pawelbaran
Copy link
Member

@BHoMBot check ready-to-merge

Copy link

bhombot-ci bot commented Oct 17, 2024

@pawelbaran to confirm, the following actions are now queued:

  • check ready-to-merge

@IsakNaslundBh IsakNaslundBh merged commit 2bb21bb into develop Oct 17, 2024
13 checks passed
@IsakNaslundBh IsakNaslundBh deleted the Geometry_Enigne-#3235-RefactorPolylineOffset branch October 17, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Error or unexpected behaviour type:feature New capability or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Geometry_Engine: Offset polyLine not working as expected
2 participants