forked from pyvista/pyvista
/
export.py
679 lines (554 loc) · 24.3 KB
/
export.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
"""
This module holds a set of tools for exporting a VTK rendering window
to a VTKjs file that can be viewed in a web browser.
PVGeo has a webveiwer_ set up to load these files.
.. _webviewer: http://viewer.pyvista.org
Much of this export script was adopted from the
`VTKjs export script for ParaView`_.
.. VTKjs export script for ParaView: https://github.com/Kitware/vtk-js/blob/master/Utilities/ParaView/export-scene-macro.py
The license for the original export script is as follows:
Copyright (c) 2016, Kitware Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT
HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
import errno
import gzip
import hashlib
import json
import os
import shutil
import sys
import time
import zipfile
import vtk
FILENAME_EXTENSION = '.vtkjs'
arrayTypesMapping = ' bBhHiIlLfdL' # last one is idtype
jsMapping = {
'b': 'Int8Array',
'B': 'Uint8Array',
'h': 'Int16Array',
'H': 'Int16Array',
'i': 'Int32Array',
'I': 'Uint32Array',
'l': 'Int32Array',
'L': 'Uint32Array',
'f': 'Float32Array',
'd': 'Float64Array'
}
writer_mapping = {}
# -----------------------------------------------------------------------------
def get_range_info(array, component):
"""Get the data range of the array's component"""
r = array.GetRange(component)
comp_range = {}
comp_range['min'] = r[0]
comp_range['max'] = r[1]
comp_range['component'] = array.GetComponentName(component)
return comp_range
# -----------------------------------------------------------------------------
def get_ref(dest_dir, md5):
"""Get reference"""
ref = {}
ref['id'] = md5
ref['encode'] = 'BigEndian' if sys.byteorder == 'big' else 'LittleEndian'
ref['basepath'] = dest_dir
return ref
# -----------------------------------------------------------------------------
objIds = []
def get_object_id(obj):
"""Get object identifier"""
try:
idx = objIds.index(obj)
return idx + 1
except ValueError:
objIds.append(obj)
return len(objIds)
# -----------------------------------------------------------------------------
def dump_data_array(dataset_dir, data_dir, array, root=None, compress=True):
"""Dump vtkjs data arry"""
if root is None:
root = {}
if not array:
return None
if array.GetDataType() == 12:
# IdType need to be converted to Uint32
array_size = array.GetNumberOfTuples() * array.GetNumberOfComponents()
new_array = vtk.vtkTypeUInt32Array()
new_array.SetNumberOfTuples(array_size)
for i in range(array_size):
new_array.SetValue(i, -1 if array.GetValue(i) <
0 else array.GetValue(i))
pbuffer = memoryview(new_array)
else:
pbuffer = memoryview(array)
pMd5 = hashlib.md5(pbuffer).hexdigest()
ppath = os.path.join(data_dir, pMd5)
with open(ppath, 'wb') as f:
f.write(pbuffer)
if compress:
with open(ppath, 'rb') as f_in, gzip.open(os.path.join(data_dir, pMd5 + '.gz'), 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
# Close then remove.
os.remove(ppath)
root['ref'] = get_ref(os.path.relpath(data_dir, dataset_dir), pMd5)
root['vtkClass'] = 'vtkDataArray'
root['name'] = array.GetName()
root['dataType'] = jsMapping[arrayTypesMapping[array.GetDataType()]]
root['numberOfComponents'] = array.GetNumberOfComponents()
root['size'] = array.GetNumberOfComponents() * array.GetNumberOfTuples()
root['ranges'] = []
if root['numberOfComponents'] > 1:
for i in range(root['numberOfComponents']):
root['ranges'].append(get_range_info(array, i))
root['ranges'].append(get_range_info(array, -1))
else:
root['ranges'].append(get_range_info(array, 0))
return root
# -----------------------------------------------------------------------------
def dump_color_array(dataset_dir, data_dir, color_array_info, root=None, compress=True):
"""Dump vtkjs color array"""
if root is None:
root = {}
root['pointData'] = {
'vtkClass': 'vtkDataSetAttributes',
"activeGlobalIds": -1,
"activeNormals": -1,
"activePedigreeIds": -1,
"activeScalars": -1,
"activeTCoords": -1,
"activeTensors": -1,
"activeVectors": -1,
"arrays": []
}
root['cellData'] = {
'vtkClass': 'vtkDataSetAttributes',
"activeGlobalIds": -1,
"activeNormals": -1,
"activePedigreeIds": -1,
"activeScalars": -1,
"activeTCoords": -1,
"activeTensors": -1,
"activeVectors": -1,
"arrays": []
}
root['fieldData'] = {
'vtkClass': 'vtkDataSetAttributes',
"activeGlobalIds": -1,
"activeNormals": -1,
"activePedigreeIds": -1,
"activeScalars": -1,
"activeTCoords": -1,
"activeTensors": -1,
"activeVectors": -1,
"arrays": []
}
colorArray = color_array_info['colorArray']
location = color_array_info['location']
dumped_array = dump_data_array(dataset_dir, data_dir, colorArray, {}, compress)
if dumped_array:
root[location]['activeScalars'] = 0
root[location]['arrays'].append({'data': dumped_array})
return root
# -----------------------------------------------------------------------------
def dump_t_coords(dataset_dir, data_dir, dataset, root=None, compress=True):
"""dump vtkjs texture coordinates"""
if root is None:
root = {}
tcoords = dataset.GetPointData().GetTCoords()
if tcoords:
dumped_array = dump_data_array(dataset_dir, data_dir, tcoords, {}, compress)
root['pointData']['activeTCoords'] = len(root['pointData']['arrays'])
root['pointData']['arrays'].append({'data': dumped_array})
# -----------------------------------------------------------------------------
def dump_normals(dataset_dir, data_dir, dataset, root=None, compress=True):
"""dump vtkjs normal vectors"""
if root is None:
root = {}
normals = dataset.GetPointData().GetNormals()
if normals:
dumped_array = dump_data_array(dataset_dir, data_dir, normals, {}, compress)
root['pointData']['activeNormals'] = len(root['pointData']['arrays'])
root['pointData']['arrays'].append({'data': dumped_array})
# -----------------------------------------------------------------------------
def dump_all_arrays(dataset_dir, data_dir, dataset, root=None, compress=True):
"""Dump all data arrays to vtkjs"""
if root is None:
root = {}
root['pointData'] = {
'vtkClass': 'vtkDataSetAttributes',
"activeGlobalIds": -1,
"activeNormals": -1,
"activePedigreeIds": -1,
"activeScalars": -1,
"activeTCoords": -1,
"activeTensors": -1,
"activeVectors": -1,
"arrays": []
}
root['cellData'] = {
'vtkClass': 'vtkDataSetAttributes',
"activeGlobalIds": -1,
"activeNormals": -1,
"activePedigreeIds": -1,
"activeScalars": -1,
"activeTCoords": -1,
"activeTensors": -1,
"activeVectors": -1,
"arrays": []
}
root['fieldData'] = {
'vtkClass': 'vtkDataSetAttributes',
"activeGlobalIds": -1,
"activeNormals": -1,
"activePedigreeIds": -1,
"activeScalars": -1,
"activeTCoords": -1,
"activeTensors": -1,
"activeVectors": -1,
"arrays": []
}
# Point data
pd = dataset.GetPointData()
pd_size = pd.GetNumberOfArrays()
for i in range(pd_size):
array = pd.GetArray(i)
if array:
dumped_array = dump_data_array(
dataset_dir, data_dir, array, {}, compress)
root['pointData']['activeScalars'] = 0
root['pointData']['arrays'].append({'data': dumped_array})
# Cell data
cd = dataset.GetCellData()
cd_size = pd.GetNumberOfArrays()
for i in range(cd_size):
array = cd.GetArray(i)
if array:
dumped_array = dump_data_array(
dataset_dir, data_dir, array, {}, compress)
root['cellData']['activeScalars'] = 0
root['cellData']['arrays'].append({'data': dumped_array})
return root
# -----------------------------------------------------------------------------
def dump_poly_data(dataset_dir, data_dir, dataset, color_array_info, root=None, compress=True):
"""Dump poly data object to vtkjs"""
if root is None:
root = {}
root['vtkClass'] = 'vtkPolyData'
container = root
# Points
points = dump_data_array(dataset_dir, data_dir,
dataset.GetPoints().GetData(), {}, compress)
points['vtkClass'] = 'vtkPoints'
container['points'] = points
# Cells
_cells = container
# Verts
if dataset.GetVerts() and dataset.GetVerts().GetData().GetNumberOfTuples() > 0:
_verts = dump_data_array(dataset_dir, data_dir,
dataset.GetVerts().GetData(), {}, compress)
_cells['verts'] = _verts
_cells['verts']['vtkClass'] = 'vtkCellArray'
# Lines
if dataset.GetLines() and dataset.GetLines().GetData().GetNumberOfTuples() > 0:
_lines = dump_data_array(dataset_dir, data_dir,
dataset.GetLines().GetData(), {}, compress)
_cells['lines'] = _lines
_cells['lines']['vtkClass'] = 'vtkCellArray'
# Polys
if dataset.GetPolys() and dataset.GetPolys().GetData().GetNumberOfTuples() > 0:
_polys = dump_data_array(dataset_dir, data_dir,
dataset.GetPolys().GetData(), {}, compress)
_cells['polys'] = _polys
_cells['polys']['vtkClass'] = 'vtkCellArray'
# Strips
if dataset.GetStrips() and dataset.GetStrips().GetData().GetNumberOfTuples() > 0:
_strips = dump_data_array(dataset_dir, data_dir,
dataset.GetStrips().GetData(), {}, compress)
_cells['strips'] = _strips
_cells['strips']['vtkClass'] = 'vtkCellArray'
dump_color_array(dataset_dir, data_dir, color_array_info, container, compress)
# PointData TCoords
dump_t_coords(dataset_dir, data_dir, dataset, container, compress)
# dump_normals(dataset_dir, data_dir, dataset, container, compress)
return root
# -----------------------------------------------------------------------------
writer_mapping['vtkPolyData'] = dump_poly_data
# -----------------------------------------------------------------------------
def dump_image_data(dataset_dir, data_dir, dataset, color_array_info, root=None, compress=True):
"""Dump image data object to vtkjs"""
if root is None:
root = {}
root['vtkClass'] = 'vtkImageData'
container = root
container['spacing'] = dataset.GetSpacing()
container['origin'] = dataset.GetOrigin()
container['extent'] = dataset.GetExtent()
dump_all_arrays(dataset_dir, data_dir, dataset, container, compress)
return root
# -----------------------------------------------------------------------------
writer_mapping['vtkImageData'] = dump_image_data
# -----------------------------------------------------------------------------
def write_data_set(file_path, dataset, output_dir, color_array_info, new_name=None, compress=True):
"""write dataset to vtkjs"""
fileName = new_name if new_name else os.path.basename(file_path)
dataset_dir = os.path.join(output_dir, fileName)
data_dir = os.path.join(dataset_dir, 'data')
if not os.path.exists(data_dir):
os.makedirs(data_dir)
root = {}
root['metadata'] = {}
root['metadata']['name'] = fileName
writer = writer_mapping[dataset.GetClassName()]
if writer:
writer(dataset_dir, data_dir, dataset, color_array_info, root, compress)
else:
print(dataObject.GetClassName(), 'is not supported')
with open(os.path.join(dataset_dir, "index.json"), 'w') as f:
f.write(json.dumps(root, indent=2))
return dataset_dir
### ----------------------------------------------------------------------- ###
### Main script contents ###
### ----------------------------------------------------------------------- ###
def mkdir_p(path):
"""Make directory at path"""
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else:
raise
def export_plotter_vtkjs(plotter, filename, compress_arrays=False):
"""Export a plotter's rendering window to the VTKjs format.
"""
sceneName = os.path.split(filename)[1]
doCompressArrays = compress_arrays
# Generate timestamp and use it to make subdirectory within the top level output dir
timeStamp = time.strftime("%a-%d-%b-%Y-%H-%M-%S")
root_output_directory = os.path.split(filename)[0]
output_dir = os.path.join(root_output_directory, timeStamp)
mkdir_p(output_dir)
renderers = plotter.ren_win.GetRenderers()
scDirs = []
sceneComponents = []
textureToSave = {}
for rIdx in range(renderers.GetNumberOfItems()):
renderer = renderers.GetItemAsObject(rIdx)
renProps = renderer.GetViewProps()
for rpIdx in range(renProps.GetNumberOfItems()):
renProp = renProps.GetItemAsObject(rpIdx)
if not renProp.GetVisibility():
continue
if hasattr(renProp, 'GetMapper') and renProp.GetMapper() is not None:
mapper = renProp.GetMapper()
dataObject = mapper.GetInputDataObject(0, 0)
dataset = None
if dataObject is None:
continue
if dataObject.IsA('vtkCompositeDataSet'):
if dataObject.GetNumberOfBlocks() == 1:
dataset = dataObject.GetBlock(0)
else:
gf = vtk.vtkCompositeDataGeometryFilter()
gf.SetInputData(dataObject)
gf.Update()
dataset = gf.GetOutput()
else:
dataset = mapper.GetInput()
if dataset and not isinstance(dataset, (vtk.vtkPolyData, vtk.vtkImageData)):
# All data must be PolyData surfaces
gf = vtk.vtkGeometryFilter()
gf.SetInputData(dataset)
gf.Update()
dataset = gf.GetOutputDataObject(0)
if dataset:# and dataset.GetPoints(): # NOTE: vtkImageData does not have points
componentName = 'data_%d_%d' % (
rIdx, rpIdx) # getComponentName(renProp)
scalarVisibility = mapper.GetScalarVisibility()
#arrayAccessMode = mapper.GetArrayAccessMode()
#colorArrayName = mapper.GetArrayName() #TODO: if arrayAccessMode == 1 else mapper.GetArrayId()
colorMode = mapper.GetColorMode()
scalarMode = mapper.GetScalarMode()
lookupTable = mapper.GetLookupTable()
dsAttrs = None
arrayLocation = ''
if scalarVisibility:
if scalarMode == 3 or scalarMode == 1: # VTK_SCALAR_MODE_USE_POINT_FIELD_DATA or VTK_SCALAR_MODE_USE_POINT_DATA
dsAttrs = dataset.GetPointData()
arrayLocation = 'pointData'
# VTK_SCALAR_MODE_USE_CELL_FIELD_DATA or VTK_SCALAR_MODE_USE_CELL_DATA
elif scalarMode == 4 or scalarMode == 2:
dsAttrs = dataset.GetCellData()
arrayLocation = 'cellData'
colorArray = None
dataArray = None
if dsAttrs:
dataArray = dsAttrs.GetArray(0) # Force getting the active array
if dataArray:
# component = -1 => let specific instance get scalar from vector before mapping
colorArray = lookupTable.MapScalars(
dataArray, colorMode, -1)
colorArrayName = '__CustomRGBColorArray__'
colorArray.SetName(colorArrayName)
colorMode = 0
else:
colorArrayName = ''
color_array_info = {
'colorArray': colorArray,
'location': arrayLocation
}
scDirs.append(write_data_set('', dataset, output_dir, color_array_info,
new_name=componentName, compress=doCompressArrays))
# Handle texture if any
textureName = None
if renProp.GetTexture() and renProp.GetTexture().GetInput():
textureData = renProp.GetTexture().GetInput()
textureName = 'texture_%d' % get_object_id(textureData)
textureToSave[textureName] = textureData
representation = renProp.GetProperty().GetRepresentation(
) if hasattr(renProp, 'GetProperty') else 2
colorToUse = renProp.GetProperty().GetDiffuseColor(
) if hasattr(renProp, 'GetProperty') else [1, 1, 1]
if representation == 1:
colorToUse = renProp.GetProperty().GetColor() if hasattr(
renProp, 'GetProperty') else [1, 1, 1]
pointSize = renProp.GetProperty().GetPointSize(
) if hasattr(renProp, 'GetProperty') else 1.0
opacity = renProp.GetProperty().GetOpacity() if hasattr(
renProp, 'GetProperty') else 1.0
edgeVisibility = renProp.GetProperty().GetEdgeVisibility(
) if hasattr(renProp, 'GetProperty') else false
p3dPosition = renProp.GetPosition() if renProp.IsA(
'vtkProp3D') else [0, 0, 0]
p3dScale = renProp.GetScale() if renProp.IsA(
'vtkProp3D') else [1, 1, 1]
p3dOrigin = renProp.GetOrigin() if renProp.IsA(
'vtkProp3D') else [0, 0, 0]
p3dRotateWXYZ = renProp.GetOrientationWXYZ(
) if renProp.IsA('vtkProp3D') else [0, 0, 0, 0]
sceneComponents.append({
"name": componentName,
"type": "httpDataSetReader",
"httpDataSetReader": {
"url": componentName
},
"actor": {
"origin": p3dOrigin,
"scale": p3dScale,
"position": p3dPosition,
},
"actorRotation": p3dRotateWXYZ,
"mapper": {
"colorByArrayName": colorArrayName,
"colorMode": colorMode,
"scalarMode": scalarMode
},
"property": {
"representation": representation,
"edgeVisibility": edgeVisibility,
"diffuseColor": colorToUse,
"pointSize": pointSize,
"opacity": opacity
},
"lookupTable": {
"tableRange": lookupTable.GetRange(),
"hueRange": lookupTable.GetHueRange() if hasattr(lookupTable, 'GetHueRange') else [0.5, 0]
}
})
if textureName:
sceneComponents[-1]['texture'] = textureName
# Save texture data if any
for key, val in textureToSave.items():
write_data_set('', val, output_dir, None, new_name=key,
compress=doCompressArrays)
cameraClippingRange = plotter.camera.GetClippingRange()
sceneDescription = {
"fetchGzip": doCompressArrays,
"background": plotter.background_color,
"camera": {
"focalPoint": plotter.camera.GetFocalPoint(),
"position": plotter.camera.GetPosition(),
"viewUp": plotter.camera.GetViewUp(),
"clippingRange": [ elt for elt in cameraClippingRange ]
},
"centerOfRotation": plotter.camera.GetFocalPoint(),
"scene": sceneComponents
}
indexFilePath = os.path.join(output_dir, 'index.json')
with open(indexFilePath, 'w') as outfile:
json.dump(sceneDescription, outfile, indent=4)
# -----------------------------------------------------------------------------
# Now zip up the results and get rid of the temp directory
sceneFileName = os.path.join(
root_output_directory, '%s%s' % (sceneName, FILENAME_EXTENSION))
try:
import zlib
compression = zipfile.ZIP_DEFLATED
except:
compression = zipfile.ZIP_STORED
zf = zipfile.ZipFile(sceneFileName, mode='w')
try:
for dirName, subdirList, fileList in os.walk(output_dir):
for fname in fileList:
fullPath = os.path.join(dirName, fname)
relPath = '%s/%s' % (sceneName,
os.path.relpath(fullPath, output_dir))
zf.write(fullPath, arcname=relPath, compress_type=compression)
finally:
zf.close()
shutil.rmtree(output_dir)
print('Finished exporting dataset to: ', sceneFileName)
def convert_dropbox_url(url):
"""Convert dropbox url to direct download link"""
return url.replace("https://www.dropbox.com", "https://dl.dropbox.com")
def generate_viewer_url(dataURL):
"""Generate viewer url with data link"""
viewerURL = "http://viewer.pyvista.org/"
return viewerURL + '%s%s' % ("?fileURL=", dataURL)
def get_vtkjs_url(*args):
"""After using ``export_vtkjs()`` to create a ``.vtkjs`` file from a
data scene which is uploaded to an online file hosting service like Dropbox,
use this method to get a shareable link to that scene on the
`PVGeo VTKjs viewer`_.
.. _PVGeo VTKjs viewer: http://viewer.pyvista.org
**Current file hosts supported:**
- Dropbox
Args:
host (str): the name of the file hosting service.
inURL (str): the web URL to the ``.vtkjs`` file.
"""
if len(args) == 1:
host = 'dropbox'
inURL = args[0]
elif len(args) == 2:
host = args[0]
inURL = args[1]
else:
raise RuntimeError('Arguments not understood.')
if host.lower() == "dropbox":
convertURL = convert_dropbox_url(inURL)
else:
print("--> Warning: Web host not specified or supported. URL is simply appended to standalone scene loader link.")
convertURL = inURL
#print("--> Your link: %s" % generate_viewer_url(convertURL))
return generate_viewer_url(convertURL)