Skip to content

Conversation

@lottilotte
Copy link
Contributor

@lottilotte lottilotte commented Sep 29, 2021

added new features in a backwards-compatible manner together with example files:

  • added NurbsCurve.segment(...)
  • added NurbsCurve.segmented(...)
  • added NurbsCurve.closest_point(...)

What type of change is this?

  • Bug fix in a backwards-compatible manner.
  • New feature in a backwards-compatible manner.
  • Breaking change: bug fix or new feature that involve incompatible API changes.
  • Other (e.g. doc update, configuration, etc)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I added a line to the CHANGELOG.md file in the Unreleased section under the most fitting heading (e.g. Added, Changed, Removed).
  • I ran all tests on my computer and it's all green (i.e. invoke test).
  • I ran lint on my computer and there are no errors (i.e. invoke lint).
  • I added new functions/classes and made them available on a second-level import, e.g. compas.datastructures.Mesh.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

Returns
-------
None
Copy link
Member

Choose a reason for hiding this comment

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

return value should be updated to the type of the returned object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the segment (vs. segmented) nothing is returned actually (using the same convention as in compas, e.g transform vs. transformed). -> in that case, should there then be no Return section at all? (in compas this appears inconsistent, sometimes it returns None, sometimes there is no return at all...)

Copy link
Member

Choose a reason for hiding this comment

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

returning nothing or returning None is the same. but you are right that the return type was indeed correct since the curve is modified in place

return GCPnts_AbscissaPoint_Length(GeomAdaptor_Curve(self.occ_curve))

def segment(self, u: float, v: float, precision: float = 1e-3) -> None:
"""Modifies this curve by segmenting it between the parameters u and v.
Copy link
Member

Choose a reason for hiding this comment

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

could you add a comment about what segmenting actually is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean...
Maybe something like " a segment is a portion of the curve bounded by the points of two curve parameters u and v." ?

Copy link
Member

Choose a reason for hiding this comment

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

to something like "Reduces the curve to the segment between parameters u and v." is a lot more descriptive of what actually happens

Comment on lines +673 to +674
if u < s or v > e:
raise ValueError('At least one of the given parameters is outside the curve domain.')
Copy link
Member

Choose a reason for hiding this comment

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

as far as i understand the OCC docs, is this requirement not necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the case of e.g. u<v, Occ gives this error:
"RuntimeError: Standard_ConstructionErrorGeom_BSplineCurve::InsertKnots raised from method Segment of class Geom_BSplineCurve"
it just doesn't really become clear in my opinion what the problem is in this descriptionion.
What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

yes just leave it as is...

raise ValueError('At least one of the given parameters is outside the curve domain.')
if u == v:
raise ValueError('The given domain is zero length.')
else:
Copy link
Member

Choose a reason for hiding this comment

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

this else is not necessary because the if triggers an error

point = Point.from_occ(projector.NearestPoint())
if not parameter:
return point
else:
Copy link
Member

Choose a reason for hiding this comment

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

else is not necessary because if already returns

@tomvanmele tomvanmele merged commit 9285bc0 into compas-dev:main Oct 22, 2021
@tomvanmele
Copy link
Member

btw, i took the liberty of already making those changes and merging the PR

@lottilotte
Copy link
Contributor Author

thanks for that!

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