# How to create surface between two closed lines?

**URL:** https://discourse.vtk.org/t/how-to-create-surface-between-two-closed-lines/14258
**Category:** Support
**Created:** [July 19, 2024, 9:47am UTC](https://discourse.vtk.org/t/how-to-create-surface-between-two-closed-lines/14258 "2024-07-19T09:47:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bassfaye](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ba9def/32.png) [@bassfaye](https://discourse.vtk.org/u/bassfaye)
#### Post date: [July 19, 2024, 9:47am UTC](https://discourse.vtk.org/t/how-to-create-surface-between-two-closed-lines/14258/1 "2024-07-19T09:47:07Z")

</div>

Hello,  
I have two closed lines like ellipsoids. I want to join them by creating a surface between them. Final mesh must be like a truncated cone but bases are the two previous closed lines.  
How can I proceed?  
Thanks in advance.

---

<div class="post-metadata">

### Author: ![rexthor](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rexthor/32/6481_2.png) [@rexthor](https://discourse.vtk.org/u/rexthor)
#### Post date: [July 19, 2024, 1:15pm UTC](https://discourse.vtk.org/t/how-to-create-surface-between-two-closed-lines/14258/2 "2024-07-19T13:15:51Z")

</div>

Sounds like you might be looking for [this filter](https://vtk.org/doc/nightly/html/classvtkRuledSurfaceFilter.html#details): vtkRuledSurfaceFilter  
An example:

```python
import vtk
import numpy as np
from math import gcd

def polygon(nverts, z):
    pline = vtk.vtkPolyLine()
    pline.GetPointIds().SetNumberOfIds(nverts + 1)
    for ind in range(nverts):
        angle = 2 * np.pi * ind/nverts
        points.InsertNextPoint(np.cos(angle), np.sin(angle), z)
        pline.GetPointIds().SetId(ind, points.GetNumberOfPoints() - 1)
    pline.GetPointIds().SetId(nverts, points.GetNumberOfPoints() - nverts)
    return pline

pd = vtk.vtkPolyData()
points = vtk.vtkPoints()
cells = vtk.vtkCellArray()

cells.InsertNextCell(polygon(3, 0)) # triangle at z = 0
cells.InsertNextCell(polygon(4, 1)) # square at z = 1
cells.InsertNextCell(polygon(5, 2)) # pentagon at z = 2

pd = vtk.vtkPolyData()
pd.SetPoints(points)
pd.SetLines(cells)

rs = vtk.vtkRuledSurfaceFilter()
rs.SetInputData(pd)
rs.SetResolution(5*4*3, 7) # first is along curve, second is along tube
rs.SetRuledModeToResample()
# rs.Update()

w = vtk.vtkXMLPolyDataWriter()
w.SetInputConnection(rs.GetOutputPort())
w.SetFileName("hi." + w.GetDefaultFileExtension())
w.Write()

```

---

<div class="post-metadata">

### Author: ![bassfaye](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ba9def/32.png) [@bassfaye](https://discourse.vtk.org/u/bassfaye)
#### Post date: [July 26, 2024, 7:33am UTC](https://discourse.vtk.org/t/how-to-create-surface-between-two-closed-lines/14258/3 "2024-07-26T07:33:51Z")

</div>

Thanks for your reply. Exactly what I need.
