While rendering using HTTP what has to be the file format. I am rendering the file as content disposition and the vtk.js is not able to render and says no input in the console of the browser.

I don’t understand. HTTP is a network protocol, not a rendering technique or technology?

I guess if we start from the beginning:

  • What it your data format? (.vtp, .vti, .dicom, .stl, .obj, …)
  • What type of rendering? (geometry vs volume)
  • What does not work? Please provide context to your issue with code snippet.

This is my index.js

import ‘vtk.js/Sources/favicon’;

import vtkActor from ‘vtk.js/Sources/Rendering/Core/Actor’;

import vtkFullScreenRenderWindow from ‘vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow’;

import vtkMapper from ‘vtk.js/Sources/Rendering/Core/Mapper’;

import vtkPolyDataReader from ‘vtk.js/Sources/IO/Legacy/PolyDataReader’;

const fileName = ‘sphere.vtk’; // ‘uh60.vtk’; // ‘luggaBody.vtk’;

const fileName = file

const BASE_PATH = http://localhost:8000

// ----------------------------------------------------------------------------

// Standard rendering code setup

// ----------------------------------------------------------------------------

const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance();

const renderer = fullScreenRenderer.getRenderer();

const renderWindow = fullScreenRenderer.getRenderWindow();

const resetCamera = renderer.resetCamera;

const render = renderWindow.render;

// ----------------------------------------------------------------------------

// Example code

// ----------------------------------------------------------------------------

const reader = vtkPolyDataReader.newInstance();

reader.setUrl(${__BASE_PATH__}/${fileName}).then(() => {

const polydata = reader.getOutputData(0);

const mapper = vtkMapper.newInstance();

const actor = vtkActor.newInstance();



// mapper.setInputData(polydata);





// // -----------------------------------------------------------

// // Make some variables global so that you can inspect and

// // modify objects in your browser’s developer console:

// // -----------------------------------------------------------

global.reader = reader;

global.fullScreenRenderer = fullScreenRenderer;

This is my server code

from django.shortcuts import render
from django.contrib.auth.models import User, Group
from rest_framework import viewsets
from rest_framework import permissions
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
from django.http import HttpResponse
from django.http import JsonResponse
from wsgiref.util import FileWrapper
import vtk

Create your views here.

def req_file(request, format = None):
List all code snippets, or create a new snippet.
if request.method == ‘GET’:
file_location = ‘server/assets/DEM30168_surface_FIBULA.vtk’
# reader = vtk.vtkPolyDataReader()
# reader.SetFileName(file_location)
# reader.Update()
# polydata = reader.GetOutput()
with open(file_location, ‘rb’) as f:
file_data =

            # sending response 
            response = HttpResponse(file_data, content_type='application/force-download')
            response['Content-Disposition'] = 'attachment; filename="output.vtk"'
            return response

    except IOError:
        # handle file not exist case here
        response = {'msg': 'file not found'}
        return JsonResponse(response)

Kindly review this and let me where things are going wrong

The above are the two code snippets of the front end and the backend I am trying to render a file from the web server and render it using vtk.js. All I get is a grey screen. I am using a .vtk model.

The code seems fine. But just so you know the VTK legacy reader has some limitation.
It was written quickly in a plane so we could get some geometry in. I would recommend using the vtp format if you can.

If I try to render .vtp or any other format the attached screenshot is what appears

Do you choose the correct reader when you change the file format that you serve?
Can you load your vtp inside ParaView Glance?

It seems the reader is giving you an empty polydata. Probably because it can not load/decode your file.

Which loader can load the vtp file and httpdatasetreader can load what formats?

I tried the same .vtp file in paraview glance. It is able to load over there.

Yeah paraview Glance can load the same .vtp file and I am trying all different loaders to the load the file. But some say no input, some loaders search for index.json like http://localhost:8000/file/index.json which i don’t understand