|
8 | 8 | from compas_rhino.conversions import point_to_compas |
9 | 9 | from compas_rhino.conversions import vector_to_compas |
10 | 10 | from compas_rhino.conversions import plane_to_compas_frame |
| 11 | +from compas_rhino.conversions import plane_to_rhino |
11 | 12 | from compas_rhino.conversions import box_to_compas |
12 | 13 | from compas_rhino.conversions import xform_to_rhino |
13 | 14 | from compas_rhino.conversions import sphere_to_rhino |
@@ -167,6 +168,25 @@ def from_rhino(cls, rhino_surface): |
167 | 168 | curve.rhino_surface = rhino_surface |
168 | 169 | return curve |
169 | 170 |
|
| 171 | + @classmethod |
| 172 | + def from_plane(cls, plane, box): |
| 173 | + """Construct a surface from a plane. |
| 174 | +
|
| 175 | + Parameters |
| 176 | + ---------- |
| 177 | + plane : :class:`compas.geometry.Plane` |
| 178 | + The plane. |
| 179 | +
|
| 180 | + Returns |
| 181 | + ------- |
| 182 | + :class:`~compas_rhino.geometry.RhinoSurface` |
| 183 | +
|
| 184 | + """ |
| 185 | + plane = plane_to_rhino(plane) |
| 186 | + box = Rhino.Geometry.BoundingBox(box.xmin, box.ymin, box.zmin, box.xmax, box.ymax, box.zmax) |
| 187 | + rhino_surface = Rhino.Geometry.PlaneSurface.CreateThroughBox(plane, box) |
| 188 | + return cls.from_rhino(rhino_surface) |
| 189 | + |
170 | 190 | # ============================================================================== |
171 | 191 | # Conversions |
172 | 192 | # ============================================================================== |
@@ -337,3 +357,25 @@ def aabb(self, precision=0.0, optimal=False): |
337 | 357 | """ |
338 | 358 | box = self.rhino_surface.GetBoundingBox(optimal) |
339 | 359 | return box_to_compas(Rhino.Geometry.Box(box)) |
| 360 | + |
| 361 | + def intersections_with_curve(self, curve, tolerance=1e-3, overlap=1e-3): |
| 362 | + """Compute the intersections with a curve. |
| 363 | +
|
| 364 | + Parameters |
| 365 | + ---------- |
| 366 | + line : :class:`~compas.geometry.Curve` |
| 367 | +
|
| 368 | + Returns |
| 369 | + ------- |
| 370 | + list[:class:`~compas.geometry.Point`] |
| 371 | +
|
| 372 | + """ |
| 373 | + intersections = Rhino.Geometry.Intersect.Intersection.CurveSurface( |
| 374 | + curve.rhino_curve, self.rhino_surface, tolerance, overlap |
| 375 | + ) |
| 376 | + points = [] |
| 377 | + for event in intersections: |
| 378 | + if event.IsPoint: |
| 379 | + point = point_to_compas(event.PointA) |
| 380 | + points.append(point) |
| 381 | + return points |
0 commit comments