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.
Sounds like you might be looking for this filter: vtkRuledSurfaceFilter
An example:
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()
Thanks for your reply. Exactly what I need.