From bf15d3b32dfb4d6ae132033f44ba3c1961a9d5cf Mon Sep 17 00:00:00 2001 From: ananya Date: Fri, 28 Feb 2025 11:49:01 +0100 Subject: [PATCH 1/6] trim and change seam methods --- src/compas_rhino/geometry/curves/curve.py | 35 +++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/compas_rhino/geometry/curves/curve.py b/src/compas_rhino/geometry/curves/curve.py index 6b3eab7c5fa8..dfc2d9f4d899 100644 --- a/src/compas_rhino/geometry/curves/curve.py +++ b/src/compas_rhino/geometry/curves/curve.py @@ -401,5 +401,36 @@ def smooth(self): def split(self): raise NotImplementedError - def trim(self): - raise NotImplementedError + def trimmed(self, t0, t1): + """Trim the curve to a specific domain. + + Parameters + ---------- + t0 : float + The start of the domain. + t1 : float + The end of the domain. + + Returns + ------- + :class:`compas_rhino.geometry.RhinoCurve` + The trimmed curve. + """ + + curve = self.native_curve.Trim(t0, t1) + return RhinoCurve.from_native(curve) + + def change_seam(self, t): + """Change the seam of the curve to a specific parameter. + + Parameters + ---------- + t : float + The parameter at which to set the seam. + + Returns + ------- + None + + """ + self.native_curve.ChangeClosedCurveSeam(t) From a3c3a17c604932047ca5bf987d5544a1c269f554 Mon Sep 17 00:00:00 2001 From: ananya Date: Fri, 28 Feb 2025 13:00:55 +0100 Subject: [PATCH 2/6] trim method --- src/compas_rhino/geometry/curves/curve.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/compas_rhino/geometry/curves/curve.py b/src/compas_rhino/geometry/curves/curve.py index dfc2d9f4d899..b9039d4fa005 100644 --- a/src/compas_rhino/geometry/curves/curve.py +++ b/src/compas_rhino/geometry/curves/curve.py @@ -401,6 +401,23 @@ def smooth(self): def split(self): raise NotImplementedError + def trim(self, t0, t1): + """Trim the curve to a specific domain. + + Parameters + ---------- + t0 : float + The start of the domain. + t1 : float + The end of the domain. + + Returns + ------- + None + + """ + self.native_curve = self.native_curve.Trim(t0, t1) + def trimmed(self, t0, t1): """Trim the curve to a specific domain. From 46c8fdaa3e970ddf31dac7ab29a60a7ca499d70f Mon Sep 17 00:00:00 2001 From: ananya Date: Fri, 28 Feb 2025 13:06:09 +0100 Subject: [PATCH 3/6] docstring offset --- src/compas_rhino/geometry/curves/curve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compas_rhino/geometry/curves/curve.py b/src/compas_rhino/geometry/curves/curve.py index b9039d4fa005..4e771b0d8172 100644 --- a/src/compas_rhino/geometry/curves/curve.py +++ b/src/compas_rhino/geometry/curves/curve.py @@ -375,7 +375,7 @@ def fair(self, tol=1e-3): raise NotImplementedError def offset(self, distance, direction, tolerance=1e-3): - """Compute the length of the curve. + """Offset the curve. Parameters ---------- From 506d20daf339e2e8b1746a01577aba01cc6f05a6 Mon Sep 17 00:00:00 2001 From: ananya Date: Fri, 28 Feb 2025 13:25:02 +0100 Subject: [PATCH 4/6] point at length --- src/compas_rhino/geometry/curves/curve.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/compas_rhino/geometry/curves/curve.py b/src/compas_rhino/geometry/curves/curve.py index 4e771b0d8172..fa707531179b 100644 --- a/src/compas_rhino/geometry/curves/curve.py +++ b/src/compas_rhino/geometry/curves/curve.py @@ -203,6 +203,22 @@ def point_at(self, t): point = self.native_curve.PointAt(t) # type: ignore return point_to_compas(point) + def point_at_length(self, length): + """Compute a point on the curve at a specific length. + + Parameters + ---------- + length : float + The length along the curve. + + Returns + ------- + :class:`compas.geometry.Point` + The corresponding point on the curve. + + """ + return point_to_compas(self.native_curve.PointAtLength(length)) # type: ignore + def tangent_at(self, t): """Compute the tangent vector at a point on the curve. From baf1b9a2f5264ec24f726bbc0e936f78870000d4 Mon Sep 17 00:00:00 2001 From: ananya Date: Fri, 28 Feb 2025 13:53:36 +0100 Subject: [PATCH 5/6] update changelog --- AUTHORS.md | 1 + CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index f97e56e08840..1d301a703fce 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -41,3 +41,4 @@ - Adam Anouar <> [@AdamAnouar](https://github.com/AdamAnouar) - Joseph Kenny <> [@jckenny59](https://github.com/jckenny59) - Panayiotis Papacharalambous <> [@papachap](https://github.com/papachap) +- Ananya Kango <> [@kangoananya](https://github.com/kangoananya) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2866a7f4016f..07ef71447cf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Fixed unexpected behavior for method `Plane.is_parallel` for opposite normals. ### Added +* Added `trim`, `trimmed`, `change_seam` and `point_at_length` methods to `RhinoCurve` class. ### Changed From bb685e0585b215225241087237259190c1e23879 Mon Sep 17 00:00:00 2001 From: ananya Date: Fri, 28 Feb 2025 14:05:32 +0100 Subject: [PATCH 6/6] formatting --- src/compas_rhino/geometry/curves/curve.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/compas_rhino/geometry/curves/curve.py b/src/compas_rhino/geometry/curves/curve.py index fa707531179b..01abb52d2c05 100644 --- a/src/compas_rhino/geometry/curves/curve.py +++ b/src/compas_rhino/geometry/curves/curve.py @@ -217,7 +217,8 @@ def point_at_length(self, length): The corresponding point on the curve. """ - return point_to_compas(self.native_curve.PointAtLength(length)) # type: ignore + point = self.native_curve.PointAtLength(length) # type: ignore + return point_to_compas(point) def tangent_at(self, t): """Compute the tangent vector at a point on the curve. @@ -432,7 +433,7 @@ def trim(self, t0, t1): None """ - self.native_curve = self.native_curve.Trim(t0, t1) + self.native_curve = self.native_curve.Trim(t0, t1) # type: ignore def trimmed(self, t0, t1): """Trim the curve to a specific domain. @@ -450,7 +451,7 @@ def trimmed(self, t0, t1): The trimmed curve. """ - curve = self.native_curve.Trim(t0, t1) + curve = self.native_curve.Trim(t0, t1) # type: ignore return RhinoCurve.from_native(curve) def change_seam(self, t): @@ -466,4 +467,4 @@ def change_seam(self, t): None """ - self.native_curve.ChangeClosedCurveSeam(t) + self.native_curve.ChangeClosedCurveSeam(t) # type: ignore