Surface From Fill

../_images/example_surface_from_fill.png
# type: ignore

from compas.geometry import NurbsCurve
from compas.geometry import NurbsSurface
from compas.geometry import Point

from compas_view2.app import App

points1 = [Point(0, -10, 0), Point(1, -8, 0), Point(-1, -6, 0), Point(0, -4, 0)]
points2 = [Point(5, -10, 0), Point(4, -8, 0), Point(6, -6, 0), Point(5, -4, 0)]

nurbscurve1 = NurbsCurve.from_interpolation(points1)
nurbscurve2 = NurbsCurve.from_interpolation(points2)

nurbssurface_2curves = NurbsSurface.from_fill(nurbscurve1, nurbscurve2)

points3 = [Point(0, 0, 0), Point(1, 2, 0), Point(-1, 4, 0), Point(0, 6, 0)]
points4 = [Point(0, 6, 0), Point(3, 6, -1), Point(5, 6, 0)]
points5 = [Point(5, 6, 0), Point(4, 2, 0), Point(5, 0, 0)]
points6 = [Point(5, 0, 0), Point(2, -1, 1), Point(0, 0, 0)]

nurbscurve3 = NurbsCurve.from_interpolation(points3)
nurbscurve4 = NurbsCurve.from_interpolation(points4)
nurbscurve5 = NurbsCurve.from_interpolation(points5)
nurbscurve6 = NurbsCurve.from_interpolation(points6)

nurbssurface_4curves = NurbsSurface.from_fill(
    nurbscurve3,
    nurbscurve4,
    nurbscurve5,
    nurbscurve6,
    style="curved",
)


# ==============================================================================
# Visualisation
# ==============================================================================

view = App()

view.add(nurbscurve1.to_polyline(), linewidth=3, linecolor=(1, 0, 0))
view.add(nurbscurve2.to_polyline(), linewidth=3, linecolor=(0, 1, 0))

view.add(nurbscurve3.to_polyline(), linewidth=3, linecolor=(1, 0, 0))
view.add(nurbscurve4.to_polyline(), linewidth=3, linecolor=(0, 1, 0))
view.add(nurbscurve5.to_polyline(), linewidth=3, linecolor=(1, 0, 1))
view.add(nurbscurve6.to_polyline(), linewidth=3, linecolor=(0, 0, 1))

view.add(nurbssurface_2curves)
view.add(nurbssurface_4curves)

view.run()