Below is a script that constructs a square perimeter with a triangle perimeter inside
I would like to construct a surface between the triangle and the square. Is there a way to do this without e.g. manually constructing vtkQuads or vtkTriangles?
import vtk
# Square points and lines
points = [
[0, 0, 0],
[1, 0, 0],
[1, 1, 0],
[0, 1, 0],
]
lines = [
[0, 1],
[1, 2],
[2, 3],
[3, 0],
]
# Inner triangle points and lines
points += [
[0.25, 0.25, 0],
[0.75, 0.25, 0],
[0.5, 0.75, 0],
]
lines += [
[4, 5],
[5, 6],
[6, 4],
]
num_points = len(points)
num_lines = len(lines)
# Create a cell array out of these points
edges = vtk.vtkCellArray()
for i in range(num_lines):
line = vtk.vtkLine()
line.GetPointIds().SetId(0, lines[i][0])
line.GetPointIds().SetId(1, lines[i][1])
edges.InsertNextCell(line)
# Create a polydata object
square = vtk.vtkPolyData()
square.SetPoints(vtk.vtkPoints())
square.SetLines(edges)
# Add the points to the dataset
for i in range(num_points):
square.GetPoints().InsertPoint(i, points[i])
# Create a mapper
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(square)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindow.SetWindowName("Square")
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderWindow.Render()
renderWindowInteractor.Start()