<jupyter_start><jupyter_text>Importing VTK data to be displayed as MeshAdditional requirements for this example: `vtk`We will also see how to do some processing with `vtk` and visualize its results.<jupyter_code>import k3d
import os
import vtk
import numpy as np

from k3d.helpers import download

filename = download('https://raw.githubusercontent.com/naucoin/VTKData/master/Data/cow.vtp')

model_matrix = (
     1.0,  0.0, 0.0, 0.0,
     0.0,  0.0, 1.0, 0.0,
     0.0,  1.0, 0.0, 0.0,
     0.0,  0.0, 0.0, 1.0
)

reader = vtk.vtkXMLPolyDataReader()
reader.SetFileName(filename)
reader.Update()

plot = k3d.plot()
cow3d = k3d.vtk_poly_data(reader.GetOutput(), color=0xff0000, model_matrix=model_matrix)
plot += cow3d
plot.display()
f = open('./output.html', 'w', encoding='UTF-8')
f.write(plot.get_snapshot(9))
f.close()
cow3d.wireframe = True
cow3d.wireframe = False
plane=vtk.vtkPlane()
plane.SetOrigin(0,0,0)
plane.SetNormal(1,1,0)
 
cutter=vtk.vtkCutter()
cutter.SetCutFunction(plane)
cutter.SetInputConnection(reader.GetOutputPort())
cutter.Update()

FeatureEdges = vtk.vtkFeatureEdges()
FeatureEdges.SetInputConnection(cutter.GetOutputPort())
FeatureEdges.BoundaryEdgesOn()
FeatureEdges.FeatureEdgesOff()
FeatureEdges.NonManifoldEdgesOff()
FeatureEdges.ManifoldEdgesOff()
FeatureEdges.Update()

cutStrips = vtk.vtkStripper() ; #Forms loops (closed polylines) from cutter
cutStrips.SetInputConnection(cutter.GetOutputPort())
cutStrips.Update()

cutPoly = vtk.vtkPolyData() ; #This trick defines polygons as polyline loop
cutPoly.SetPoints((cutStrips.GetOutput()).GetPoints())
cutPoly.SetPolys((cutStrips.GetOutput()).GetLines())
model_matrix = (
     1.0,  0.0, 0.0, 0.0,
     0.0,  0.0, 1.0, -5.0,
     0.0,  1.0, 0.0, 0.0,
     0.0,  0.0, 0.0, 1.0
)
plot += k3d.vtk_poly_data(cutPoly, color=0x0000ff,  model_matrix=model_matrix)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14469453376205788, 'fraction_numerical': 0.04876741693461951, 'mean_word_length': 5.0814332247557, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '376973', 'license': 'MIT', 'n_tokens_mistral': 773, 'n_tokens_neox': 750, 'n_words': 139, 'path': 'examples/vtk.ipynb', 'repo_name': 'tgandor/K3D-jupyter', 'size': '1866'}