I am using VTK for creating my meshes. I am new to it and I am facing 2 issues.
- I can’t find proper documentation to add holes into polygon mesh
- Polygon curves have issue
My Code sample is:
def extrude_polygon(vertices, holes, extrude):
cell = vtkIdList()
points = [[point[0], point[1]] for point in vertices]
# points = remove_recursion(points)
# Create points
poly_points = vtkPoints()
poly_points.SetDataTypeToDouble()
[(poly_points.InsertNextPoint(pt[0], pt[1], 0), cell.InsertNextId(i)) for i, pt in enumerate(points)]
# Create a PolyData object and add points
pd = vtkPolyData()
pd.Allocate(1, 1)
pd.SetPoints(poly_points)
# pd.InsertNextCell(VTK_POLYGON, cell)
pd.InsertNextCell(vtkConstants.VTK_POLYGON, cell)
prod = vtkTrivialProducer()
prod.SetOutput(pd)
extr = vtkLinearExtrusionFilter()
extr.SetInputConnection(prod.GetOutputPort())
extr.SetVector(0, 0, extrude)
pn = vtkPolyDataNormals()
pn.SetInputConnection(extr.GetOutputPort())
pn.AutoOrientNormalsOn()
return pn
Current Output:
Expected Output: